-
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
ComboboxControl: SuggestionsList loses focus on DOWN key press #38548
Comments
Key |
I have tested it in a similar environment and confirmed that the same symptom occurs with The option does not change and it loses focus if there is a block or title element before / after the For some reason, I think the keyboard events are not working. Please see: 05e9b68efa61a5aa0ba1622777ce4bcf.mp4
Environment info
|
Just for the information, gutenberg/packages/components/src/form-token-field/index.js Lines 141 to 189 in 5c0b338
I'm unable to check it now, but maybe (a) it has the same issue (b) the issue is already fixed there. |
I this caused by some parts of the code attaching the event listener directly to the DOM instead of handling the event via React? Doing this and passing
|
I am investigating, but have created code to temporarily enable the block so that anyone can reproduce this issue. Code( function ( blocks, components, element, blockEditor ) {
const el = element.createElement;
blocks.registerBlockType( 'create-block/test-block', {
title: '#38548 Test Block',
apiVersion: 2,
icon: 'smiley',
category: 'text',
edit: function () {
return el(
'div',
blockEditor.useBlockProps({
style: {
backgroundColor: '#eee',
padding: '16px',
border: '1px solid #aaa',
}
}),
el( components.ComboboxControl, {
label: 'Combobox Control',
options: [
{
value: 'small',
label: 'Small',
},
{
value: 'normal',
label: 'Normal',
},
{
value: 'large',
label: 'Large',
},
{
value: 'huge',
label: 'Huge',
},
],
} )
);
},
save: function () {
return null;
},
} );
} )(
window.wp.blocks,
window.wp.components,
window.wp.element,
window.wp.blockEditor
); 18ae6210fa1bf77e7857bef0028df11c.mp4 |
I have not been able to solve this problem, but I will describe what I have learned from my research so far in the hope that someone else will be able to solve this problem. First, in the gutenberg/packages/components/src/combobox-control/index.js Lines 121 to 128 in eeeccf6
If there is a focusable element (block or title) above or below, starting from the block containing the What occurs instead is the vertical movement of the caret (i.e., the movement of the block in focus) in the gutenberg/packages/block-editor/src/components/writing-flow/use-arrow-nav.js Lines 263 to 270 in eeeccf6
If we were to comment out the However, in the gutenberg/packages/components/src/combobox-control/index.js Lines 135 to 154 in eeeccf6
And in the gutenberg/packages/block-editor/src/components/writing-flow/use-arrow-nav.js Lines 221 to 224 in eeeccf6
However, for some reason I think we need to add the appropriate treatment to either I have given it a hoge label and hope someone familiar with this issue can solve it. |
@t-hamano did you look into this #38548 (comment)? From what I can tell, event handlers that are registered this way take precedence over those registered via React, which makes the event bubbling super confusing. |
So, if we register an event handler via React in |
If I remember correctly, and assuming that my findings were correct, the problem is not in So a quick and dirty fix is to make This was all a few months back though, and right now I've got a two month old baby taking up all of my time, so I don't have the time to confirm any of this. |
But if you find the code that changes the selection and set a breakpoint there as well as in |
Thanks for the informative info! |
Yeah, that's such a fundamental architectural change that I just backed away slowly once I got that far 😕 |
I have confirmed that the approach described in this comment solves this problem on the block editor. However, there is no longer a proper way to "escape" from the I believe this is inappropriate in terms of accessibility and would like to explore what keystrokes would be appropriate. |
There are already cases where the special arrow key handling of the Writing Flow is just not compatible with a control's own standard arrow key handling. For example, a standard I would argue that we should first honor the standard arrow controls of the underlying component (combobox in this case), rather than prioritize the Writing Flow edge navigation, as this is more of an enhancement on top of the standard controls. In that vein, one possible way to address might be to add |
Description
Whole block including
ComboboxControl
loses focus onDOWN
key press.Step-by-step reproduction instructions
ComboboxControl
DOWN
Expected behavior: selected next option.
Actual behavior: block loses focus, options hidden.
Screenshots, screen recording, code snippet
https://developer.wordpress.org/block-editor/reference-guides/components/combobox-control/
Keys should be handled properly, source:
gutenberg/packages/components/src/combobox-control/index.js
Lines 107 to 141 in 39f883e
Environment info
Please confirm that you have searched existing issues in the repo.
Yes
Please confirm that you have tested with all plugins deactivated except Gutenberg.
Yes
The text was updated successfully, but these errors were encountered: