-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Pattern Categories Select: Stop event propagation for the select element's onBlur to fix behaviour in iOS #30717
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
Pattern Categories Select: Stop event propagation for the select element's onBlur to fix behaviour in iOS #30717
Conversation
|
✅ Tested and confirmed this fixes the problem. No knock on effects for selecting a pattern in the post editor. |
|
@andrewserong There is one test failing related to the site editor that should be checked first. |
|
This is the failing test. I've tested these changes in the site editor as well (both iOS and web) and cannot see how they are related to this particular failing test. |
80f1178 to
c13a4a3
Compare
|
Thanks for testing @ramonjd! I've just given this a rebase to see if that gets it passing... |
|
That test is still failing after a rebase, but just double-checked and it's failing on other PRs, so I believe it's unrelated. |
… fix issue in iOS
c13a4a3 to
d07ae0f
Compare
|
@apeatling I've rebased, and the tests are passing on this one now. Are you happy to merge this in (I don't have access yet), or do you think we should get another pair of 👀 from other folks? |
|
Let's merge it because it's a bit of a nasty one and I think this is a good fix. |


Related to: #29243
Description
Fix the pattern inserter closing on iOS when switching pattern categories.
As raised in #29243 in iOS when you go to change pattern categories within the pattern inserter, selecting an option from the Select drop-down fires an onBlur event that bubbles up to the parent (in this case I believe it's the
useDialogattached to the inserter panel).This unexpected onBlur event bubbling causes the inserter to close when the user switches pattern categories. To prevent this from happening, in this change, we update the Pattern Inserter Panel to add an
onBlurfunction that stops event propagation if the blur event does not have a related target. When a user clicks from the select element into the editor canvas (e.g. in a web browser) then there will typically be anevent.relatedTarget. We can use the absence of this as a check to prevent the inserter from closing on iOS.Note: we might be able to pursue a similar fix directly in the useDialog / use, but this didn't seem quite as safe, since we can't know for certain how the
useDialogoruseFocusOutsideis being used in other contexts, whereas for the pattern category drop-down, if we are accidentally a bit greedy about stopping propagation, the side-effect is likely going to be negligible.How has this been tested?
Manually, in a web browser, and in iOS Simulator via XCode.
In iOS simulator (or running this PR on a real iOS mobile device):
Screenshots
Types of changes
Bug fix
Checklist:
*.native.jsfiles for terms that need renaming or removal).