-
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
Fix link popover keyboard accessibility #10983
Conversation
@@ -426,7 +426,13 @@ export class RichText extends Component { | |||
return; | |||
} | |||
|
|||
const { start, end } = this.createRecord(); | |||
const { start, end, formats } = this.createRecord(); |
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.
createRecord
creates a new record form the DOM. getRecord
gets the current record from props. Also I think this might be better to do in onChange right before or after you update the global state. You have direct access to the record there. Thanks!
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.
looks like onChange only triggers when typing instead of when using cursor keys or changing selection with the mouse like I need.
The createRecord was there before, should it be getRecord instead?
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.
Oh, never mind then, I only saw the green line. :) Then this looks good, sorry!
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.
No worries - thanks for taking a look. 😄
@@ -399,7 +400,7 @@ export class BlockListBlock extends Component { | |||
// We render block movers and block settings to keep them tabbale even if hidden | |||
const shouldRenderMovers = ! isFocusMode && ( isSelected || hoverArea === 'left' ) && ! showEmptyBlockSideInserter && ! isMultiSelecting && ! isPartOfMultiSelection && ! isTypingWithinBlock; | |||
const shouldShowBreadcrumb = ! isFocusMode && isHovered && ! isEmptyDefaultBlock; | |||
const shouldShowContextualToolbar = ! hasFixedToolbar && ! showSideInserter && ( ( isSelected && ! isTypingWithinBlock ) || isFirstMultiSelected ); | |||
const shouldShowContextualToolbar = ! hasFixedToolbar && ! showSideInserter && ( ( isSelected && ( ! isTypingWithinBlock || isCaretWithinFormattedText ) ) || isFirstMultiSelected ); |
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.
These bools scare me - might be worth refactoring them into functions or something?
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.
Definitely yes, I recall them being quite scary the last time I worked on this file.
Might be worth a separate code quality issue as a follow-up, unless you have the time to do it now 😄
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.
Thanks a million, this was the bug that was irking me the most in the merge milestone.
Just one comment about "leave" vs "exit", but after that: 🚢
docs/data/data-core-editor.md
Outdated
|
||
Returns an action object used in signalling that the caret has entered formatted text. | ||
|
||
### leaveFormattedText |
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.
Would this be better-named as exitFormattedText
? It matches enterFormattedText
more, and the docs confused me at first because I read "left" as in "left/right" not "left/leave".
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.
👍 changed this
@@ -388,4 +388,36 @@ describe( 'Links', () => { | |||
await page.keyboard.press( 'Escape' ); | |||
expect( await page.$( '.editor-url-popover' ) ).toBeNull(); | |||
} ); | |||
|
|||
it( 'can be modified using the keyboard once a link has been set', async () => { |
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.
❤️ for the test!
Ah, hold off one second, getting some weird behaviour in Firefox, let me see... |
Never mind, my build was buggy; fixed it. Confirmed to be working for me with the keyboard. Awesome, thanks, ship it! 👍 |
The only slightly weird thing is that it looks like the toolbar shows when your cursor is adjacent to the inline token but the token isn't itself highlighted. Not the end of the world, but it jumped out at me. Either way this looks like an improvement! |
Can we make the link popover not move around? I could have sworn it used to anchor itself to the link... maybe #6113 regressed... |
@noisysocks - I might look at that on a separate PR today. I think it'll be related to this component: It might have been one my past changes that caused it to regress as I put out a fix to make it recalculate position whenever the selection changes - there was an issue where it didn't change position when clicking between links. @chrisvanpatten - I see what you mean, and it works differently on the left and right side of the format. I think I can iron out the left/right inconsistency, but the highlighting of formatting is internal to tinymce (they're called inline boundaries), would have to hook into that somehow. |
Looking some more the inconsistency with how the toolbar is displayed on the leading and trailing edge of formatted text is a bit of a deeper problem. Currently if the caret is on the trailing edge of formatted text, the toolbar button to toggle the format doesn't work, but on the leading edge it does work. The logic in this PR for displaying the toolbar is consistent with that. I think it's worth filing a separate issue to look at fixing both things at once. |
Thanks for working on this! Quickly tested, I've noticed the same thing @chrisvanpatten and @talldan mentioned about the highlighting and inline boundaries (not only an inconsistency between left and right behaviors but it's also different from Classic Editor). Regardless, makes perfectly sense to me to try to address that separately. This PR is a good improvement for keyboard users and I'm all for it. Thank you. |
7b7144a
to
ac5d270
Compare
@@ -372,6 +372,7 @@ export class BlockListBlock extends Component { | |||
isPartOfMultiSelection, | |||
isFirstMultiSelected, | |||
isTypingWithinBlock, | |||
isCaretWithinFormattedText, |
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 don't like that the block's wrapper is aware of something very specific to the implementation of a given block (RichText). It doesn't seem like a generic enough solution for me. All blocks don't use RichText. As I see it the block wrapper should work similarily no matter what's the content of the edit
function.
That said, I'm not familiar enough with the issue and the PR to propose an alternative. (which means I won't block this PR either)
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.
That's a good point. I don't have a better solution either off the top of my head, aside from just documenting that it's RichText
specific, which still isn't great/is the whole problem. 🤷♂️
Let's rebase and merge. |
ac5d270
to
7e4c15f
Compare
Rebased and pushed, just waiting on Travis and then I'll get this merged. |
Urgh, something went wrong with the rebase, looking into it now... |
Rebase fixed… will merge when ready 😄 |
a20ba53
to
97dfc04
Compare
const { start, end } = this.createRecord(); | ||
const { start, end, formats } = this.createRecord(); | ||
|
||
if ( formats[ start ] ) { |
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.
Could this be moved in start !== this.state.start || end !== this.state.end
you think? Could we check right here which flag is set to avoid calling the prop?
Thanks for catching that - I've got a PR here to reduce the frequency of dispatches - #11235 |
Description
Fixes #8266 by displaying the link popover whenever the caret is positioned within link formatting. As discussed in the issue, the agreed upon approach also involved displaying the toolbar whenever the caret is positioned within any formatting.
Also fixes #3350.
Changes:
How has this been tested?
Screenshots
Types of changes
New feature (non-breaking change which adds functionality)
Checklist: