Issue by petetnt
Thursday Jan 07, 2016 at 18:27 GMT
Originally opened as adobe/brackets#12060
This PR fixes the following FlipView focus issues:
Steps:
- Launch brackets and make sure the working set is empty.
- Single click on any file to have it view only.
- Enable split view. At this stage the view of the file is present in pane 1 lets assume.
- Flip view from pane 1 to pane 2.
Issue 1( Must-fix):
The focus remains on pane 1 which is expected but the editor in the destination pane still shows > the cursor. Ideally editor in the second pane should loose focus as the focus in in first pane.
Issue 2( Must-fix):
If you now click on the flipped editor in the second pane, focus switch happens to second pane as expected. But now if you try to click on the first pane focus is never retained on first pane and > immediately reverts to second pane. So at this point there is no way you can open a document in the first pane unless there is something in the working set of first pane and you click there to regain focus.
The implementation is surprisingly non-trivial due to how MainViewManager, CodeMirror and CEF in general handle their focus events.
This PR adds a new preference called pane.retainFocusAfterFlip which controls which panel gets focused after the flip. By default the setting is false, which makes the focus end up in the new panel after pressing the FlipView button; setting it true will make the currently active pane keep its focus. The default setting is purely out of my personal preference: the biggest reason for me needing a FlipView button was to have a quick way to move the new file to other pane so I can look at the one under it while I edit the new file, not the other way around. If the consensus is the other way, the default can of course be flipped.
In the implementation the focus event is deferred with setTimeout to happen after the other focus events have occurred: AFAIK there's no way to prevent all the focus/blur events that happen in editor concurrently. In the retainFocusAfterFlip scenario .focus() is also called before setting the active pane Id: otherwise the editor doesn't unblur the CodeMirror-textarea for some reason, leaving the active cursor to the wrong pane.
Another semi-interesting tidbit is the following: activePaneIdBeforeFlip is not always self.id: when the FlipView button has been clicked, the pane doesn't get the focus: this can actually be preferable, because this enables a fast way for flipping multiple views from the non-active view to the active one without losing the focus. Other way would be giving the pane the button belongs to focus when clicked, but this makes giving the focus to the correct pane after the switch even more confusing 😕.
Note that this PR is against@swmitra's BugFixesFor1.6Beta-branch instead of the master
I'll make some unit tests for these next.
ping@swmitra
petetnt included the following code: https://github.com/adobe/brackets/pull/12060/commits
Thursday Jan 07, 2016 at 18:27 GMT
Originally opened as adobe/brackets#12060
This PR fixes the following
FlipViewfocus issues:The implementation is surprisingly non-trivial due to how MainViewManager, CodeMirror and CEF in general handle their
focusevents.This PR adds a new preference called
pane.retainFocusAfterFlipwhich controls which panel gets focused after the flip. By default the setting isfalse, which makes the focus end up in the new panel after pressing the FlipView button; setting ittruewill make the currently active pane keep its focus. The default setting is purely out of my personal preference: the biggest reason for me needing a FlipView button was to have a quick way to move the new file to other pane so I can look at the one under it while I edit the new file, not the other way around. If the consensus is the other way, the default can of course be flipped.In the implementation the focus event is deferred with
setTimeoutto happen after the other focus events have occurred: AFAIK there's no way to prevent all the focus/blur events that happen in editor concurrently. In theretainFocusAfterFlipscenario.focus()is also called before setting the active pane Id: otherwise the editor doesn't unblur the CodeMirror-textarea for some reason, leaving the active cursor to the wrong pane.Another semi-interesting tidbit is the following:
activePaneIdBeforeFlipis not alwaysself.id: when theFlipViewbutton has been clicked, the pane doesn't get the focus: this can actually be preferable, because this enables a fast way for flipping multiple views from the non-active view to the active one without losing the focus. Other way would be giving the pane the button belongs to focus when clicked, but this makes giving the focus to the correct pane after the switch even more confusing 😕.Note that this PR is against
@swmitra'sBugFixesFor1.6Beta-branch instead of the masterI'll make some unit tests for these next.
ping
@swmitrapetetnt included the following code: https://github.com/adobe/brackets/pull/12060/commits