-
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: Can't type space if RichText
component is inside button/summary in Firefox
#50540
Conversation
Size Change: +67 B (0%) Total Size: 1.39 MB
ℹ️ View Unchanged
|
Interesting. I thought the fix could be applied to the details block itself. I'm maybe a little bit nervous about using |
Thanks for the advice. It appears that this issue is being actively attempted to be resolved in Firefox bug report.
If this issue is resolved in the latest version of Firefox, how do you feel about closing this PR as well, assuming #49679 is also resolved? |
I suppose it depends on how longer firefox users generally take to upgrade. I think the release cadence is monthly, so it might take a few months for users to shift over once the fix is merged. |
c63efaf
to
744a466
Compare
I think I am ready for this PR.
Although it is not common, this problem also occurs outside of the Details block. For example, if you create a custom block and insert a RichText component inside a button/summary element. To avoid affecting other events (e.g., the event where a list is generated when a space is pressed after a hyphen), I have made it so that it is only processed when it is inside a button/summary element. |
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.
This is working well for me.
It might be good to have @ellatrix look over it too.
Also, I guess we should try to remember to remove it when the affected versions fall below a certain usage level.
@ellatrix |
I think it'd be good to get the details block out of its experimental status soon, as otherwise there's a risk of it not being ready in time for WordPress 6.3. Lets move ahead with merging this one, still plenty of time to change some things if needed after this is merged. |
Fixes: #49679
What?
This PR fixes a problem where a space could not be entered if there is a
RichText
component in thebutton
/summary
element. In the core block, this can be reproduced with the summary element in the Details block.Why?
This is a Firefox-specific issue and has been reported in bug reports, as reported in this comment. In the future, this may be fixed in Firefox itself, but it should not be a problem to fix it in Gutenberg first.
How?
I have added an event to the RichText component hook that monitors keydowns. In this event, if the space key is pressed and in a button/summary element (which is the case that causes the problem), the default event is canceled and an explicit space is added.
Testing Instructions
Insert a Details block in the Firefox browser.
In the summary element, make sure you can type the space key.
Before
before.mp4
After
after.mp4