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

Rename list view prop expandNested to isExpanded #40731

Merged
merged 4 commits into from
May 3, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
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
14 changes: 7 additions & 7 deletions packages/block-editor/src/components/list-view/branch.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ function ListViewBranch( props ) {
isBranchSelected = false,
listPosition = 0,
fixedListWindow,
expandNested,
isExpanded,
} = props;

const {
Expand All @@ -115,7 +115,7 @@ function ListViewBranch( props ) {
filteredBlocks[ index - 1 ],
expandedState,
draggedClientIds,
expandNested
isExpanded
);
}

Expand All @@ -133,8 +133,8 @@ function ListViewBranch( props ) {
const hasNestedBlocks =
showNestedBlocks && !! innerBlocks && !! innerBlocks.length;

const isExpanded = hasNestedBlocks
? expandedState[ clientId ] ?? expandNested
const shouldExpand = hasNestedBlocks
? expandedState[ clientId ] ?? isExpanded
: undefined;

const isDragged = !! draggedClientIds?.includes( clientId );
Expand Down Expand Up @@ -164,7 +164,7 @@ function ListViewBranch( props ) {
siblingBlockCount={ blockCount }
showBlockMovers={ showBlockMovers }
path={ updatedPath }
isExpanded={ isExpanded }
isExpanded={ shouldExpand }
listPosition={ nextPosition }
selectedClientIds={ selectedClientIds }
/>
Expand All @@ -174,7 +174,7 @@ function ListViewBranch( props ) {
<td className="block-editor-list-view-placeholder" />
</tr>
) }
{ hasNestedBlocks && isExpanded && ! isDragged && (
{ hasNestedBlocks && shouldExpand && ! isDragged && (
<ListViewBranch
blocks={ innerBlocks }
selectBlock={ selectBlock }
Expand All @@ -186,7 +186,7 @@ function ListViewBranch( props ) {
fixedListWindow={ fixedListWindow }
isBranchSelected={ isSelectedBranch }
selectedClientIds={ selectedClientIds }
expandNested={ expandNested }
isExpanded={ isExpanded }
/>
) }
</AsyncModeProvider>
Expand Down
6 changes: 3 additions & 3 deletions packages/block-editor/src/components/list-view/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export const BLOCK_LIST_ITEM_HEIGHT = 36;
* @param {boolean} props.__experimentalPersistentListViewFeatures Flag to enable features for the Persistent List View experiment.
* @param {boolean} props.__experimentalHideContainerBlockActions Flag to hide actions of top level blocks (like core/widget-area)
* @param {string} props.id Unique identifier for the root list element (primarily for a11y purposes).
* @param {boolean} props.expandNested Flag to determine whether nested levels are expanded by default.
* @param {boolean} props.isExpanded Flag to determine whether nested levels are expanded by default.
* @param {Object} ref Forwarded ref
*/
function ListView(
Expand All @@ -72,7 +72,7 @@ function ListView(
showNestedBlocks,
showBlockMovers,
id,
expandNested = false,
isExpanded = false,
...props
},
ref
Expand Down Expand Up @@ -225,7 +225,7 @@ function ListView(
showBlockMovers={ showBlockMovers }
fixedListWindow={ fixedListWindow }
selectedClientIds={ selectedClientIds }
expandNested={ expandNested }
isExpanded={ isExpanded }
{ ...props }
/>
</ListViewContext.Provider>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export default function NavigationMenu( { innerBlocks, id } ) {
<ListView
id={ id }
showNestedBlocks
expandNested={ false }
isExpanded={ false }
getdave marked this conversation as resolved.
Show resolved Hide resolved
__experimentalFeatures
__experimentalPersistentListViewFeatures
/>
Expand Down