Skip to content

Commit

Permalink
Close patterns modal on insertion and focus on inserted pattern (Word…
Browse files Browse the repository at this point in the history
…Press#68975)

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

0 comments on commit df6f07d

Please sign in to comment.