Skip to content

Commit

Permalink
add expand on hover back
Browse files Browse the repository at this point in the history
  • Loading branch information
draganescu committed Sep 24, 2024
1 parent 16d52c1 commit fa43644
Showing 1 changed file with 29 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,27 +22,32 @@ import { unlock } from '../../lock-unlock';

export function ZoomOutSeparator( { clientId, rootClientId = '' } ) {
const [ isDraggedOver, setIsDraggedOver ] = useState( false );
const { sectionRootClientId, sectionClientIds, isBlockSelected } =
useSelect( ( select ) => {
const {
getBlockInsertionPoint,
getBlockOrder,
isBlockInsertionPointVisible,
getSectionRootClientId,
isBlockSelected: _isBlockSelected,
} = unlock( select( blockEditorStore ) );
const {
sectionRootClientId,
sectionClientIds,
isBlockSelected,
blockInsertionPoint,
blockInsertionPointVisible,
} = useSelect( ( select ) => {
const {
getBlockInsertionPoint,
getBlockOrder,
isBlockInsertionPointVisible,
getSectionRootClientId,
isBlockSelected: _isBlockSelected,
} = unlock( select( blockEditorStore ) );

const root = getSectionRootClientId();
const sectionRootClientIds = getBlockOrder( root );
return {
isBlockSelected: _isBlockSelected,
sectionRootClientId: root,
sectionClientIds: sectionRootClientIds,
blockOrder: getBlockOrder( root ),
blockInsertionPoint: getBlockInsertionPoint(),
blockInsertionPointVisible: isBlockInsertionPointVisible(),
};
}, [] );
const root = getSectionRootClientId();
const sectionRootClientIds = getBlockOrder( root );
return {
isBlockSelected: _isBlockSelected,
sectionRootClientId: root,
sectionClientIds: sectionRootClientIds,
blockOrder: getBlockOrder( root ),
blockInsertionPoint: getBlockInsertionPoint(),
blockInsertionPointVisible: isBlockInsertionPointVisible(),
};
}, [] );

const isReducedMotion = useReducedMotion();

Expand All @@ -61,7 +66,10 @@ export function ZoomOutSeparator( { clientId, rootClientId = '' } ) {
return null;
}

isVisible = isBlockSelected( clientId );
isVisible =
isBlockSelected( clientId ) ||
( blockInsertionPointVisible &&
clientId === sectionClientIds[ blockInsertionPoint.index ] );

return (
<AnimatePresence>
Expand Down

0 comments on commit fa43644

Please sign in to comment.