Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions packages/block-editor/src/components/inserter/menu.native.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
/**
* External dependencies
*/
import { LayoutAnimation, TouchableHighlight } from 'react-native';
import {
AccessibilityInfo,
LayoutAnimation,
TouchableHighlight,
Platform,
} from 'react-native';

/**
* WordPress dependencies
Expand Down Expand Up @@ -140,7 +145,19 @@ function InserterMenu( {

const onSelectItem = useCallback(
( item ) => {
onInsert( item );
// Avoid a focus loop, see https://github.com/WordPress/gutenberg/issues/30562
if ( Platform.OS === 'ios' ) {
AccessibilityInfo.isScreenReaderEnabled().then( ( enabled ) => {
// In testing, the bug focus loop needed a longer timeout when VoiceOver was enabled
const timeout = enabled ? 200 : 100;
// eslint-disable-next-line @wordpress/react-no-unsafe-timeout
setTimeout( () => {
onInsert( item );
}, timeout );
} );
} else {
onInsert( item );
}
onSelect( item );
},
[ onInsert, onSelect ]
Expand Down