-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Inserting a root node does not update focus correctly #591
Comments
I'll take a stab at this one. Some questions you might be able to answer for me though: We track state for "focused node" and "selected nodes", which are both separate from the browser's Would this be a correct explanation of the semantics:
How editing actions work:
Of the above editing actions, the only one that operates on "selected nodes" is "deleting nodes". When the "focused node" changes, document.activeElement is updated to point to the dom element corresponding to that focused node. But if document.activeElement is changed through a different mechanism, the "focused node" does not change. Do I have all this right? Do tests for this behavior belong in "activation-tests"? Is there a semantic difference in the meaning behind "activation" vs "focus"? |
When editing a text file, sighted users have to consider one bit of state at a time: "where is the cursor?", or "what is selected?" When something is selected, their cursor sort of melts into one end of the most-recent selection. Visually-impaired (VI) users must always keep track of where their "focus cursor" is at all times. When nothing is selected, their focus cursor is synonymous with the actual cursor. But if something is selected, their focus cursor persists and can move around without modifying the selection! We refer to the node that is focused as being "activated", thus We have to track focusId separately from We also have to track selection separately from Your semantics for selected nodes, focused node, and activeElement are all correct deleting nodes - Mostly correct. Only selected nodes can be deleted. Sina recommended this, since a destructive operation should require users to "opt in" by hitting the spacebar. This will change both the selection state (nothing selected) and the focused node (computed based on the edit). copying nodes - hitting Ctrl-C should copy the focused node and all selected nodes. It does not change selection state, or the focused node. cutting nodes - the same as hitting copy and then delete. If nodes A and B are selected and node C is focused, then all three are copied and A+B are deleted. C retains focus. pasting nodes - If a node is selected, pasting will replace it with the clipboard contents. If nothing is selected, editing nodes - your semantics are exactly right. inserting nodes - your semantics are exactly right. One addendum - if you hit "enter" when editing and save the edit, focus switches to the last child of the inserted subtree. dragging to the trash - same as "deleting nodes". One thing I don't believe we've spec'd out is dragging an item to the trash when multiple nodes are selected. My instinct is to say that we only delete the dragged node, and we leave selection alone unless the dragged node happened to also be selected. In general, I've tried to put all of the tests regarding active/focus updates into
So ideally, that's 32 tests. 40 if you count paste-before (Shift-Ctrl-V) as a separate action. Many of these tests are already in in the suite, but I'm certain we need more. I'm happy to own organizing and writing whatever is missing, though I've hit a wall when it comes to mocking paste and drag events. |
Thank you for providing such a thorough response to my questions. I'll need to review this carefully to make sure I understand everything. |
Describe the bug
Inserting
a b c
as root nodes - anywhere in the document - should put focus onc
when the editor is re-rendered. Instead, focus is lost.To Reproduce
Steps to reproduce the behavior:
quuz
, and typea b c
.Expected behavior
a
,b
, andc
appear as root nodes, withc
activatedDesktop (please complete the following information):
Additional context
This would make a good test case for #468
The text was updated successfully, but these errors were encountered: