-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Writing Flow: Fix all the broken flows #5513
Conversation
Regression of #5025, where prop was changed from `previousBlock` to `previousBlockUid`, but neglected to update the instance of the prop reference in keydown handler
4391553
to
9425112
Compare
Escape doesn't clear focus, so causes problems that block is not selected but retains focus (since isSelected state is synced with focus)
Previously only closed on esc when editing link, not adding new link TODO: Consolidate editing state
9425112
to
5886309
Compare
Thank you so much for working on this. This is a 🔥PR and a masterclass in code. 👏
Works really well 🌟
🌟
🌟 Agree that it's unclear what is the ideal behavior here. It sort of conflicts with #4382 (comment), but there isn't wide consensus on the approach outlined there, so we can always revisit if and when that becomes necessary.
🌟
🌟
🌟 🔥
🌟
🌟
🌟 CC: @iseulde I think this is desired behavior, it feels right, but I feel like Ella and I discussed in the past what happened if you were in a multi input block, held shift, and arrowed. Can't recall the full details.
🌟🌟🌟
🌟🔥🚒
🌟 Amazing work! This is suuuch a vast improvement to the writing flow. Really really dig this. 👍 👍 |
Thanks for the glowing review @jasmussen ! And for running through all the steps. It's a risky move forward with the code changes, but I want this one to have some time to sit in master to let any issues surface before the pending release, so I'm going to go ahead and merge. |
Yes, this is still a to-do. See #3232. Thanks for all the work on this @aduth. I've been testing shift-arrow-multi-selection a bit, and it seems broken if you go in one direction for a while, and then the other. Not sure if this ever worked as expected but I think it did. I'm expecting shift+arrow in the opposite direction to deselect the blocks again one at the time. I'll see if I can fix this. |
Yes, this was identified as a "Known bug" of the nesting implementation (#3745 (comment), #3745 (comment)), but good to have an explicit issue for it (#5548). Thanks! |
This is awesome. |
*/ | ||
toggleEventBindings( isBound ) { | ||
const bindFn = isBound ? 'addEventListener' : 'removeEventListener'; | ||
document[ bindFn ]( 'selectionchange', this.stopTypingOnSelectionUncollapse ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm trying to recall if there was a specific reason to make this bound to the document
, vs. just an onSelectionChange
event on the div
wrapper. It was inherited from how this was applied previously, originally from #4872, where the selection handling moved from RichText
to BlockListBlock
.
The document-based mousemove
event makes sense because we want to unset typing even when the mouse is moved outside the descendents of this component. But selectionchange
? I'm not sure. That seems inconsistent with the rest of the key handling that happens here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, this would probably explain why:
This pull request seeks to remedy a number of issues with writing flow, some of which have existed for some time, some of which have been introduced (blaming myself) in recent refactorings. This includes...
tabIndex
to wrapper) and Block: Avoid rerendering when the previous/next block updates #5025 (failure to update one instance ofthis.props.previousBlock
)isSelected
is synced to itsfocus
event, but focus has never left).blur
)input
tags, they would be erroneously included in the writing flow sequence.Implementation notes:
I'm hopeful the changes here provide more stability by consolidating like behaviors and isolating typing behavior outside the block itself.
Managing
isTyping
was moved to a separate component, largely because there was conflicts withIgnoreNestedEvents
when both the block's inner and outer wrappers listen on the same block. I had started to explore providing a label to identify block handled events per block UID, but instead decided to refactor the typing logic altogether. The intention here is thatisTyping
is a global behavior, not specific to individual blocks (especially as we'd previously had handling re-settingisTyping
after a separate block becomes selected after merge/split, and had separately handled logic of "is typing within block").Because I'm guilty of causing much of these regressions in refactoring, I am committing myself to writing end-to-end tests for these behaviors.
Testing instructions:
Verify that all the writing flows work correctly. Notably all the examples above plus: