@@ -26,6 +26,7 @@ import { useLibraryRoutes } from '../routes';
2626import messages from './messages' ;
2727import { useSidebarContext } from '../common/context/SidebarContext' ;
2828import { ToastContext } from '../../generic/toast-context' ;
29+ import { canEditComponent } from '../components/ComponentEditorModal' ;
2930
3031/** Components that need large min height in preview */
3132const LARGE_COMPONENTS = [
@@ -90,6 +91,7 @@ export const LibraryUnitBlocks = ({ preview }: LibraryUnitBlocksProps) => {
9091 componentId,
9192 readOnly,
9293 setComponentId,
94+ openComponentEditor,
9395 } = useLibraryContext ( ) ;
9496
9597 const {
@@ -131,9 +133,14 @@ export const LibraryUnitBlocks = ({ preview }: LibraryUnitBlocksProps) => {
131133 closeManageTagsDrawer ( ) ;
132134 } ;
133135
134- const handleComponentSelection = ( block : LibraryBlockMetadata ) => {
136+ const handleComponentSelection = ( block : LibraryBlockMetadata , numberOfClicks : number ) => {
135137 setComponentId ( block . id ) ;
136138 navigateTo ( { componentId : block . id } ) ;
139+ const canEdit = canEditComponent ( block . id ) ;
140+ if ( numberOfClicks > 1 && canEdit ) {
141+ // Open editor on double click.
142+ openComponentEditor ( block . id ) ;
143+ }
137144 } ;
138145
139146 /* istanbul ignore next */
@@ -166,7 +173,7 @@ export const LibraryUnitBlocks = ({ preview }: LibraryUnitBlocksProps) => {
166173 } ;
167174
168175 const renderedBlocks = orderedBlocks ?. map ( ( block ) => (
169- < IframeProvider key = { block . id } >
176+ < IframeProvider key = { block . id + block . modified } >
170177 < SortableItem
171178 id = { block . id }
172179 componentStyle = { null }
@@ -179,7 +186,7 @@ export const LibraryUnitBlocks = ({ preview }: LibraryUnitBlocksProps) => {
179186 outline : hidePreviewFor === block . id && '2px dashed gray' ,
180187 } }
181188 isClickable
182- onClick = { ( ) => handleComponentSelection ( block ) }
189+ onClick = { ( e : { detail : number ; } ) => handleComponentSelection ( block , e . detail ) }
183190 disabled = { preview }
184191 >
185192 { hidePreviewFor !== block . id && (
0 commit comments