Skip to content
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: Cancel isTyping when focusing non text field #5552

Merged
merged 2 commits into from
Mar 14, 2018

Conversation

aduth
Copy link
Member

@aduth aduth commented Mar 10, 2018

This pull request seeks to cancel the isTyping flag when focus transitions to a non-text element. This is particularly helpful for reactivating toolbars in elements which don't have text fields, where previously the toolbars only reactivate when the selection becomes uncollapsed.

Testing instructions:

  1. Create new post
  2. Insert a paragraph block
  3. Insert an image block (leave as placeholder)
  4. Start typing in the paragraph block
  5. Arrow down
  6. Note that the image block is selected, and its toolbar visible
    • In master, at this point it would be impossible to use the image toolbar by keyboard alone (without convoluted steps to cancel isTyping by navigating back into the paragraph block)

@aduth aduth added [Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes). [Feature] Writing Flow Block selection, navigation, splitting, merging, deletion... labels Mar 10, 2018
};
} ),
withDispatch( ( dispatch ) => {
const { startTyping, stopTyping } = dispatch( 'core/editor' );
Copy link
Member

@jorgefilipecosta jorgefilipecosta Mar 12, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice syntax 👍

Copy link
Member

@jorgefilipecosta jorgefilipecosta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to work as advertised and cancels the isTyping. The code looks good 👍

I noticed that when are not typing (the toolbar is visible in the paragraph) and we use the arrow down to go to the image. The image toolbar does not appear, this PR solves the case when we are typing so I think this scenario may also deserve an improvement in other PR as it is another case that may need to be handled.

@aduth
Copy link
Member Author

aduth commented Mar 13, 2018

Thanks @jorgefilipecosta . It looks like its an issue of focus being evaluated before keydown, so typing isn't stopped but the keydown handler proceeds to start typing. Adding a simple delay alleviates this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Writing Flow Block selection, navigation, splitting, merging, deletion... [Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes).
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants