Skip to content

Commit

Permalink
Pattern Categories Select: stop event propagation on Select onBlur to…
Browse files Browse the repository at this point in the history
… fix issue in iOS (#30717)

Co-authored-by: Andrew Serong <[email protected]>
  • Loading branch information
andrewserong and andrewserong authored Apr 19, 2021
1 parent b192bba commit fd2a138
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions packages/block-editor/src/components/inserter/pattern-panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,16 @@ function PatternInserterPanel( {
);
};

// In iOS-based mobile devices, the onBlur will fire when selecting an option
// from a Select element. To prevent closing the useDialog on iOS devices, we
// stop propagating the onBlur event if there is no relatedTarget, which means
// that the user most likely did not click on an element within the editor canvas.
const onBlur = ( event ) => {
if ( ! event?.relatedTarget ) {
event.stopPropagation();
}
};

return (
<>
<div className={ getPanelHeaderClassName() }>
Expand All @@ -52,6 +62,7 @@ function PatternInserterPanel( {
hideLabelFromVision
value={ selectedCategory.name }
onChange={ onChangeSelect }
onBlur={ onBlur }
options={ categoryOptions() }
/>
</div>
Expand Down

0 comments on commit fd2a138

Please sign in to comment.