-
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
Resizable Editor: Make the editor resizable with arrow keys #65546
Conversation
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Size Change: +16 B (0%) Total Size: 1.77 MB
ℹ️ View Unchanged
|
I tested in trunk and the arrow keys are still working correctly 🤔. I must be missing something. Could you share your environment, e.g. the browsers or the setup?
Either way, I think this is still a good improvement! |
Thanks for the review!
After further investigation, it appears that, as mentioned in this comment, this is due to the text cursor mode in the Chrome browser and Windows OS. When this mode is enabled, it seems that the focus may move unintentionally using the arrow keys. This mode can be disabled with the The video below is a test on trunk; in the first half, the text cursor mode is enabled, and in the second half, it is disabled: 6d472ffe5445f97e48cb9edc03f7aec4.mp4In any case, it seems that |
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 for the update! This change makes sense to me 👍
if ( keyCode !== LEFT && keyCode !== RIGHT ) { | ||
return; | ||
} | ||
event.preventDefault(); |
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.
Should we add a comment referencing this issue, or do you think it's a common practice? I think maybe it's fine to leave it to git blaming to do its work 😅.
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 think if we want to add our own event to an event, it is common to add event.preventDefault()
, and there are a lot of uncommented event.preventDefault()
in Gutenberg 😅 Therefore, I personally think that a comment is unnecessary.
What?
I found that although the resize handles of the resizable editor are keyboard focusable, pressing the left or right key takes the focus away, making it impossible to resize the editor.
Why?
This is probably due to the influence of other event handlers.
How?
As with here, check the key and add
event.preventDefault()
.Testing Instructions
Screenshots or screencast
2bebcb09b62e66f225248addc186203e.mp4