-
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 regressions and improve the insert link search field and suggestions list #10838
Conversation
* position. As the popover with the list of suggestions is now nested within | ||
* another popover, we need to get the gran parent node. | ||
*/ | ||
return anchor.parentNode.parentNode.getBoundingClientRect(); |
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 understand the logic, but I'd prefer if we find another way as this seems fragile. It used to work properly before without it (even with two popovers) so curious to know why it regressed.
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.
Yeah I agree it's fragile, that's why I've mentioned that maybe the popover component should handle these nesting cases internally. It happened to work before just by coincidence 🙂 If you look at the screenshot posted above, the suggestions list is perfectly centered to the first popover highlighted area. The ellipsis button is now outside of the first popover and doesn't contribute to determine its width, so the position calculation of the second popover takes into consideration only the highlighted area. If you move the ellipsis button back inside the first popover, then the position will work correctly (but just by coincidence).
this.props.onChange( post.url, post ); | ||
this.setState( { | ||
selectedSuggestion: null, | ||
showSuggestions: false, | ||
} ); | ||
|
||
// Announce a link has been selected when tabbing away from the input field. | ||
if ( event.keyCode === TAB ) { |
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.
Why should we only announce this on "tab" only? I prefer to do it consistently if possible.
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.
Because when pressing Enter, the form is submitted and the link gets inserted. There's another speak message for that, see "Link inserted" in submitLink()
in LinkContainer
.
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.
Gotcha, instead of passing the event object here, I'd personally just move this to the switch/case above
Thanks @youknowriad
|
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.
Nice, Thanks for the improvements.
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.
Actually, this broken the url input for the button block.
Ah, right. I see the custom |
I've reverted the custom |
Can you rebase the branch so we can get it in. |
444e68f
to
6bd3ae2
Compare
Rebased. Thank you. |
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.
LGTM 👍
@talldan has a PR been created? I've just noticed one more issue: as the ellipsis button is now placed outside, pressing Escape when it's focused or when its expanded panel is focused, doesn't close the link popover. |
Was it intentional that we only announce that the link has been selected when explicitly pressing the Tab key, and not when selecting the link via Enter ? I could see an argument being made that since it might not be expected that the link is selected when the focus shifts by pressing Tab, the spoken message helps inform the user about that effect. But if it's unexpected such that it needs to be explained, then it makes me wonder whether it should actually happen at all. In other words, would you consider either of the following as a reasonable change:
Edit: After spending more time with links (related to #19462), I'm now aware there are expected to be different specific behaviors of Tab and Enter insofar as both "select" a link, but only when pressing Enter is the link actually applied. At least, this is how it works today. It's not necessarily something that the |
Generally, the If I recall correctly, the current behavior is meant to reproduce how In a way, that's not totally unexpected. Some browsers have the same behavior on some native HTML elements. For example on a
Worth noting that when pressing Enter,
|
Fixes #10820
Additionally fixes a few CSS regressions and improves the interaction with the insert link search field and suggestions list.
First commit:
Worth noting:
8px
44px
; changed to8px
Second commit:
TAB
key populate the search field with the highlighted link URLLink added.
message toLink inserted
to match the Classic Editor messageThird commit:
regression: fixes the position of the suggestions popover after Chore - extract link container from rich text #10495URLPopover
introduced in Chore - extract link container from rich text #10495)Basically, this happens because the "Link Settings" button is now placed outside of the first popover:
Thus, the calculation of the suggestions popover is based on the search field form without the settings button. I can think of two ways to fix this:
getAnchorRect
function to get the grand parent nodeI've opted for the latter, even if a better solution would probably be making the popover component handle these nesting cases. I'd appreciate some eyes form @aduth and @talldan. If there's the need for adjustments / refinements / improvements glad if you can take this PR and make it better.
width: 100%;
from the search field because it made the following "Apply" button smaller than it's supposed to be (the correct width is 36 pixels)list-style: none;
applied on a divRe: the popover position when a popover is nested within another popover, I guess this relates also to #8468.