Skip to content
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

Inserter: Fix unresponsive Browse All Button on Quick Inserter for Mobile Screens. #67339

Open
wants to merge 2 commits into
base: trunk
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
1 change: 1 addition & 0 deletions packages/block-editor/src/components/inserter/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ class Inserter extends Component {
isAppender={ isAppender }
prioritizePatterns={ prioritizePatterns }
selectBlockOnInsert={ selectBlockOnInsert }
closeQuickInserter={ onClose }
Mamaduka marked this conversation as resolved.
Show resolved Hide resolved
/>
);
}
Expand Down
12 changes: 12 additions & 0 deletions packages/block-editor/src/components/inserter/quick-inserter.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import useInsertionPoint from './hooks/use-insertion-point';
import usePatternsState from './hooks/use-patterns-state';
import useBlockTypesState from './hooks/use-block-types-state';
import { store as blockEditorStore } from '../../store';
import { useViewportMatch } from '@wordpress/compose';

const SEARCH_THRESHOLD = 6;
const SHOWN_BLOCK_TYPES = 6;
Expand All @@ -32,6 +33,7 @@ export default function QuickInserter( {
isAppender,
prioritizePatterns,
selectBlockOnInsert,
closeQuickInserter,
hasSearch = true,
} ) {
const [ filterValue, setFilterValue ] = useState( '' );
Expand All @@ -54,6 +56,8 @@ export default function QuickInserter( {
true
);

const isMobileDevice = useViewportMatch( 'small', '<' );

const { setInserterIsOpened, insertionIndex } = useSelect(
( select ) => {
const { getSettings, getBlockIndex, getBlockCount } =
Expand Down Expand Up @@ -86,6 +90,14 @@ export default function QuickInserter( {
// When clicking Browse All select the appropriate block so as
// the insertion point can work as expected.
const onBrowseAll = () => {
if (
isMobileDevice &&
closeQuickInserter &&
typeof closeQuickInserter === 'function'
) {
closeQuickInserter();
}
Mamaduka marked this conversation as resolved.
Show resolved Hide resolved

setInserterIsOpened( {
filterValue,
onSelect,
Expand Down
Loading