Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
e179812
Add ListViewBlock with spotlight fading effect and related state mana…
ramonjd Dec 14, 2025
dee1994
Update blockEditingModes in private selectors test to ensure consiste…
ramonjd Apr 16, 2026
27a3880
Improve pattern editing list view isolation
ramonjd Jun 16, 2026
78d8e4f
Inline tabIndex condition
talldan Jun 26, 2026
32231aa
Remove redundant writing flow changes
talldan Jun 26, 2026
9897651
Use disabled block mode in List View
talldan Jun 26, 2026
40b9b23
Use disabled semantics for List View fading
talldan Jun 26, 2026
50aa9a2
Clean up List View tree selector
talldan Jun 26, 2026
bc2d308
Remove incidental List View whitespace
talldan Jun 26, 2026
16e441b
Update List View spotlight tests
talldan Jun 26, 2026
bb35348
Move List View disabled ARIA to block button
talldan Jun 26, 2026
9b5607b
Remove unnecessary event handling code, stopEditingContentOnlySection…
talldan Jun 26, 2026
103e5d7
Avoid binding disabled List View handlers
talldan Jun 26, 2026
0d5dd66
Fix disabled List View row cursor
talldan Jun 26, 2026
77e98a1
Prevent disabled List View hover color
talldan Jun 26, 2026
126a700
Remove redundant content-only focus handling
talldan Jun 26, 2026
fe0d700
Remove blank line
talldan Jun 26, 2026
d200904
Remove should wording from List View spotlight changes
talldan Jun 26, 2026
3bbd752
Clarify List View disabled block filtering
talldan Jun 26, 2026
ab66459
Make selector callback more readable
talldan Jun 26, 2026
b8abe32
Respect explicit disabled modes in List View tree
talldan Jun 26, 2026
adf98f9
Stop explicit modes from inheriting disabled parents
talldan Jun 26, 2026
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 @@ -3,7 +3,7 @@
*/
import { Button, __experimentalVStack as VStack } from '@wordpress/components';
import { __ } from '@wordpress/i18n';
import { useSelect } from '@wordpress/data';
import { useSelect, useDispatch } from '@wordpress/data';
import { isReusableBlock, isTemplatePart } from '@wordpress/blocks';

/**
Expand Down Expand Up @@ -59,11 +59,15 @@ function InlineEditButton( {
editContentOnlySection,
stopEditingContentOnlySection,
} ) {
const { selectBlock } = useDispatch( blockEditorStore );
const handleClick = () => {
if ( ! editedContentOnlySection ) {
editContentOnlySection( clientId );
selectBlock( clientId );
} else {
stopEditingContentOnlySection();
Comment thread
ramonjd marked this conversation as resolved.
Resolved
// Keep the selected section pattern or content block selected after exiting.
selectBlock( clientId );
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ function ListViewBlockSelectButton(
isExpanded,
ariaDescribedBy,
visibilityLabel,
isDisabled = false,
},
ref
) {
Expand Down Expand Up @@ -79,6 +80,8 @@ function ListViewBlockSelectButton(
}

return (
// Disabled list view items intentionally omit href so TreeGrid skips them.
// eslint-disable-next-line jsx-a11y/anchor-is-valid
<a
className={ clsx(
'block-editor-list-view-block-select-button',
Expand All @@ -94,7 +97,8 @@ function ListViewBlockSelectButton(
onDragStart={ onDragStartHandler }
onDragEnd={ onDragEnd }
draggable={ draggable }
href={ `#block-${ clientId }` }
href={ isDisabled ? undefined : `#block-${ clientId }` }
aria-disabled={ isDisabled ? true : undefined }
aria-describedby={ ariaDescribedBy }
aria-expanded={ isExpanded }
>
Expand Down
77 changes: 57 additions & 20 deletions packages/block-editor/src/components/list-view/block.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ function ListViewBlock( {
insertAfterBlock,
insertBeforeBlock,
showViewportModal,
stopEditingContentOnlySection,
} = unlock( useDispatch( blockEditorStore ) );

const debouncedToggleBlockHighlight = useDebounce(
Expand Down Expand Up @@ -125,21 +126,36 @@ function ListViewBlock( {

const pasteStyles = usePasteStyles();

const { block, blockName, allowRightClickOverrides } = useSelect(
const {
block,
blockName,
blockEditingMode,
allowRightClickOverrides,
editedSection,
} = useSelect(
( select ) => {
const { getBlock, getBlockName, getSettings } = unlock(
select( blockEditorStore )
);
const {
getBlock,
getBlockName,
getBlockEditingMode: getBlockEditingModeForClientId,
getSettings,
getEditedContentOnlySection,
} = unlock( select( blockEditorStore ) );

return {
block: getBlock( clientId ),
blockName: getBlockName( clientId ),
blockEditingMode: getBlockEditingModeForClientId( clientId ),
allowRightClickOverrides:
getSettings().allowRightClickOverrides,
editedSection: getEditedContentOnlySection(),
};
},
[ clientId ]
);

const isDisabled = blockEditingMode === 'disabled';

const { canRename } = useBlockRename( blockName );

const showBlockActions =
Expand Down Expand Up @@ -202,6 +218,13 @@ function ListViewBlock( {
return;
}

if ( editedSection && isMatch( 'core/block-editor/unselect', event ) ) {
event.stopPropagation();
event.preventDefault();
stopEditingContentOnlySection();
return;
}

const isDeleteKey = [ BACKSPACE, DELETE ].includes( event.keyCode );

// If multiple blocks are selected, deselect all blocks when the user
Expand Down Expand Up @@ -539,7 +562,8 @@ function ListViewBlock( {
);

const hasSiblings = siblingBlockCount > 0;
const hasRenderedMovers = showBlockMovers && hasSiblings;
const canShowBlockActions = showBlockActions && ! isDisabled;
const hasRenderedMovers = showBlockMovers && hasSiblings && ! isDisabled;
const moverCellClassName = clsx(
'block-editor-list-view-block__mover-cell',
{ 'is-visible': isHovered || isSelected }
Expand All @@ -553,7 +577,7 @@ function ListViewBlock( {
let colSpan;
if ( hasRenderedMovers ) {
colSpan = 2;
} else if ( ! showBlockActions ) {
} else if ( ! canShowBlockActions ) {
colSpan = 3;
}

Expand All @@ -566,12 +590,13 @@ function ListViewBlock( {
'is-dragging': isDragged,
'has-single-cell': ! showBlockActions,
'is-synced': blockInformation?.isSynced,
'is-draggable': canMoveBlock,
'is-draggable': canMoveBlock && ! isDisabled,
'is-displacement-normal': displacement === 'normal',
'is-displacement-up': displacement === 'up',
'is-displacement-down': displacement === 'down',
'is-after-dragged-blocks': isAfterDraggedBlocks,
'is-nesting': isNesting,
'is-disabled': isDisabled,
} );

// Only include all selected blocks if the currently clicked on block
Expand All @@ -582,19 +607,28 @@ function ListViewBlock( {
? selectedClientIds
: [ clientId ];

// Detect if there is a block in the canvas currently being edited and multi-selection is not happening.
const currentlyEditingBlockInCanvas =
isSelected && selectedClientIds.length === 1;
const getListViewBlockTabIndex = ( rovingTabIndex ) => {
if ( isDisabled ) {
return -1;
}

// Detect if there is a block in the canvas currently being edited and multi-selection is not happening.
if ( isSelected && selectedClientIds.length === 1 ) {
return 0;
}

return rovingTabIndex;
};

return (
<ListViewLeaf
className={ classes }
isDragged={ isDragged }
onKeyDown={ onKeyDown }
onMouseEnter={ onMouseEnter }
onMouseLeave={ onMouseLeave }
onFocus={ onMouseEnter }
onBlur={ onMouseLeave }
onMouseEnter={ isDisabled ? undefined : onMouseEnter }
onMouseLeave={ isDisabled ? undefined : onMouseLeave }
onFocus={ isDisabled ? undefined : onMouseEnter }
onBlur={ isDisabled ? undefined : onMouseLeave }
level={ level }
position={ position }
rowCount={ rowCount }
Expand All @@ -615,22 +649,25 @@ function ListViewBlock( {
<ListViewBlockContents
block={ block }
onClick={ selectEditorBlock }
onContextMenu={ onContextMenu }
onContextMenu={
isDisabled ? undefined : onContextMenu
}
onMouseDown={ onMouseDown }
onToggleExpanded={ toggleExpanded }
onToggleExpanded={
isDisabled ? undefined : toggleExpanded
}
isSelected={ isSelected }
position={ position }
siblingBlockCount={ siblingBlockCount }
level={ level }
ref={ ref }
tabIndex={
currentlyEditingBlockInCanvas ? 0 : tabIndex
}
tabIndex={ getListViewBlockTabIndex( tabIndex ) }
onFocus={ onFocus }
isExpanded={ canEditBlock ? isExpanded : undefined }
selectedClientIds={ selectedClientIds }
ariaDescribedBy={ descriptionId }
visibilityLabel={ blockVisibilityDescription }
isDisabled={ isDisabled }
/>
<AriaReferencedText id={ descriptionId }>
{ [
Expand Down Expand Up @@ -676,7 +713,7 @@ function ListViewBlock( {
</>
) }

{ showBlockActions && BlockSettingsMenu && (
{ canShowBlockActions && BlockSettingsMenu && (
<TreeGridCell
className={ listViewBlockSettingsClassName }
aria-selected={ !! isSelected }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ export default function ListViewExpander( { onClick } ) {
// For the current tree grid implementation, please do not try to make this a button.
<span
className="block-editor-list-view__expander"
onClick={ ( event ) => onClick( event, { forceToggle: true } ) }
onClick={
onClick
? ( event ) => onClick( event, { forceToggle: true } )
: undefined
}
aria-hidden="true"
data-testid="list-view-expander"
>
Expand Down
19 changes: 19 additions & 0 deletions packages/block-editor/src/components/list-view/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,25 @@
box-shadow: 0 0 0 $radius-small var(--wp-admin-theme-color);
}
}

&.is-disabled {
opacity: 0.2;
@media not ( prefers-reduced-motion ) {
transition: opacity 0.1s linear;
}

&:hover {
opacity: 0.2;
}

.block-editor-list-view__expander {
cursor: default;
}

.block-editor-list-view-block-select-button:hover {
color: inherit;
}
}
}

// First level of indentation is aria-level 2, max indent is 8.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ export default function useListViewClientIds( { blocks, rootClientId } ) {
const {
getDraggedBlockClientIds,
getSelectedBlockClientIds,
getEnabledClientIdsTree,
getListViewClientIdsTree,
} = unlock( select( blockEditorStore ) );

return {
selectedClientIds: getSelectedBlockClientIds(),
draggedClientIds: getDraggedBlockClientIds(),
clientIdsTree:
blocks ?? getEnabledClientIdsTree( rootClientId ),
blocks ?? getListViewClientIdsTree( rootClientId ),
};
},
[ blocks, rootClientId ]
Expand Down
Loading
Loading