Skip to content

Commit

Permalink
Close patterns modal on insertion and focus on inserted pattern (#68975)
Browse files Browse the repository at this point in the history
Co-authored-by: yogeshbhutkar <[email protected]>
Co-authored-by: Mamaduka <[email protected]>
Co-authored-by: t-hamano <[email protected]>
Co-authored-by: afercia <[email protected]>
Co-authored-by: carolinan <[email protected]>
  • Loading branch information
6 people authored Feb 27, 2025
1 parent 47fdb90 commit df6f07d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import PatternExplorerSidebar from './pattern-explorer-sidebar';
import PatternList from './pattern-list';
import { usePatternCategories } from '../block-patterns-tab/use-pattern-categories';

function PatternsExplorer( { initialCategory, rootClientId } ) {
function PatternsExplorer( { initialCategory, rootClientId, onModalClose } ) {
const [ searchValue, setSearchValue ] = useState( '' );
const [ selectedCategory, setSelectedCategory ] = useState(
initialCategory?.name
Expand All @@ -34,6 +34,7 @@ function PatternsExplorer( { initialCategory, rootClientId } ) {
selectedCategory={ selectedCategory }
patternCategories={ patternCategories }
rootClientId={ rootClientId }
onModalClose={ onModalClose }
/>
</div>
);
Expand All @@ -46,7 +47,7 @@ function PatternsExplorerModal( { onModalClose, ...restProps } ) {
onRequestClose={ onModalClose }
isFullScreen
>
<PatternsExplorer { ...restProps } />
<PatternsExplorer onModalClose={ onModalClose } { ...restProps } />
</Modal>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ function PatternList( {
selectedCategory,
patternCategories,
rootClientId,
onModalClose,
} ) {
const container = useRef();
const debouncedSpeak = useDebounce( speak, 500 );
Expand Down Expand Up @@ -152,7 +153,10 @@ function PatternList( {
<>
<BlockPatternsList
blockPatterns={ pagingProps.categoryPatterns }
onClickPattern={ onClickPattern }
onClickPattern={ ( pattern, blocks ) => {
onClickPattern( pattern, blocks );
onModalClose();
} }
isDraggable={ false }
/>
<BlockPatternsPaging { ...pagingProps } />
Expand Down

1 comment on commit df6f07d

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flaky tests detected in df6f07d.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/13566442184
📝 Reported issues:

Please sign in to comment.