-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Block Editor: Change default URLInput autoFocus to false
#19973
Conversation
ce1c776
to
e69aed5
Compare
e69aed5
to
0936dcf
Compare
Rebased to resolve conflicts. Removed "In Progress" label. This is awaiting review. |
Size Change: +24 B (0%) Total Size: 904 kB
ℹ️ View Unchanged
|
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 👍
There are (probably legitimate) test errors now. I'll take a look on Monday. |
I gave a quick manual test to this branch. I see that the issue which is likely causing the test failures is related to the fact that when clicking "Edit" when previewing a link, the input field isn't automatically focused. It's been some time since I originally put the changes together here, but based on the changes applied to URLInputButton in toggling a button to trigger focus to shift into the input, I expect the same treatment could/should be applied to the LinkControl toggle as well. |
0936dcf
to
9045b67
Compare
This should hopefully be fixed now as of the changes in 9045b67 . This was able to lean on some of the component's own prior art, where focus is retained when completing the selection of a link. The revised implementation essentially applies this behavior for any toggle, either the start or completion of an edit state. Note that this required a few extra considerations:
|
I added the "Needs Dev Note" label since this is technically a breaking change for existing usage of the
|
The stubs appear to be taking effect in other tests unintentionally. I'll have to take another look. It might just need to be complemented by an Or it might just be worth looking at something on the |
This has been implemented in a separate PR. Thanks Andrew |
Related #18061
Closes #22440
Blocked by: #19462This pull request seeks to change the default behavior of
URLInput
to avoid assigning auto-focus to its rendered input. Auto-focus is largely discouraged (we even enforce a rule) and it should not be the default behavior for such a basic component, as it limits (complicates) reusability and makes unnecessary assumptions about its rendering context. It's assumed that this was the default largely based on the assumption that the input is typically rendered within a Popover, which is not something we should be assuming.Note: Technically this can be considered a breaking change. That being said, if the component is used within a Popover (as was often assumed), the behavior should be unimpacted, since the default behavior of
Popover
'sfocusOnMount
prop is to focus the first focusable element, which would be the URLInput if one is present.Status: This pull request is considered to be blocked by #19462, mostly because the interactions involved with Cmd+K are such that Popover's defaultfocusOnMount
isn't strictly enough to work with the specific rendering behavior of the current inline link dialog.Testing Instructions:
Verify that URL inputs are auto-focused as you would expect them to be in popovers:
Follow-up tasks:
Should
URLInputButton
be deprecated? Or at least undocumented. I don't believe that it's used in any core blocks, and I question whether we should want to encourage it as a pattern.