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 'append-after' keyboard a11y in both modes #63298

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
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,14 @@
}
}

.block-editor-block-list__insertion-point {
opacity: 0;

&:focus-within,
.is-visible {
opacity: 1;
}
}

.components-popover.block-editor-block-popover__drop-zone {
// Disable pointer events for dragging and dropping.
Expand Down
11 changes: 5 additions & 6 deletions packages/block-editor/src/components/block-tools/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,12 +202,6 @@ export default function BlockTools( {
// eslint-disable-next-line jsx-a11y/no-static-element-interactions
<div { ...props } onKeyDown={ onKeyDown }>
<InsertionPointOpenRef.Provider value={ useRef( false ) }>
{ ! isTyping && (
<InsertionPoint
__unstableContentRef={ __unstableContentRef }
/>
) }

{ showEmptyBlockSideInserter && (
<EmptyBlockInserter
__unstableContentRef={ __unstableContentRef }
Expand Down Expand Up @@ -251,6 +245,11 @@ export default function BlockTools( {
name="__unstable-block-tools-after"
ref={ blockToolbarAfterRef }
/>
{ ! isTyping && (
<InsertionPoint
__unstableContentRef={ __unstableContentRef }
/>
) }
Copy link
Member Author

Choose a reason for hiding this comment

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

Note that the order previously didn't matter here, it was available only to pointer devices.
Also note that the zoom-out inserters are actually right below this one now.

{ window.__experimentalEnableZoomedOutPatternsTab &&
isZoomOutMode && (
<ZoomOutModeInserters
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ function InbetweenInsertionPointPopover( {
__unstableContentRef,
operation = 'insert',
nearestSide = 'right',
isVisible,
} ) {
const { selectBlock, hideInsertionPoint } = useDispatch( blockEditorStore );
const openRef = useContext( InsertionPointOpenRef );
Expand Down Expand Up @@ -78,7 +79,7 @@ function InbetweenInsertionPointPopover( {
rootClientId: insertionPoint.rootClientId,
isNavigationMode: _isNavigationMode(),
isDistractionFree: settings.isDistractionFree,
isInserterShown: insertionPoint?.__unstableWithInserter,
isInserterShown: insertionPoint?.__unstableWithInserter ?? true,
};
}, [] );
const { getBlockEditingMode } = useSelect( blockEditorStore );
Expand Down Expand Up @@ -177,6 +178,7 @@ function InbetweenInsertionPointPopover( {
onFocus={ onFocus }
className={ clsx( className, {
'is-with-inserter': isInserterShown,
'is-visible': isVisible,
} ) }
onHoverEnd={ maybeHideInserterPoint }
>
Expand Down Expand Up @@ -231,7 +233,6 @@ export default function InsertionPoint( props ) {
);

if (
! isVisible ||
// Don't render the insertion point if the block list is empty.
// The insertion point will be represented by the appender instead.
isBlockListEmpty
Expand All @@ -243,7 +244,7 @@ export default function InsertionPoint( props ) {
* Render a popover that overlays the block when the desired operation is to replace it.
* Otherwise, render a popover in between blocks for the indication of inserting between them.
*/
return insertionPoint.operation === 'replace' ? (
return isVisible && insertionPoint.operation === 'replace' ? (
<BlockDropZonePopover
// Force remount to trigger the animation.
key={ `${ insertionPoint.rootClientId }-${ insertionPoint.index }` }
Expand All @@ -253,6 +254,7 @@ export default function InsertionPoint( props ) {
<InbetweenInsertionPointPopover
operation={ insertionPoint.operation }
nearestSide={ insertionPoint.nearestSide }
isVisible={ isVisible }
{ ...props }
/>
);
Expand Down
Loading