-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
List View: Add private appender prop #49137
Conversation
Size Change: +1.46 kB (0%) Total Size: 1.34 MB
ℹ️ View Unchanged
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good so far, thanks for introducing the private version of ListView 👍
} } | ||
/> | ||
<div | ||
className="offcanvas-editor-appender__description" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
className="offcanvas-editor-appender__description" | |
className="list-view-editor-appender__description" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think all the CSS needs to be moved across.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was marked as resolved, but the scss for the appender still needs to be copied across from off canvas to list view.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I forgot to push 🤦
useEffect( () => { | ||
if ( ! insertedBlockTitle?.length ) { | ||
return; | ||
} | ||
|
||
speak( | ||
sprintf( | ||
// translators: %s: name of block being inserted (i.e. Paragraph, Image, Group etc) | ||
__( '%s block inserted' ), | ||
insertedBlockTitle | ||
), | ||
'assertive' | ||
); | ||
}, [ insertedBlockTitle ] ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This effect feels unnecessary, when it could something along the lines of:
onSelectOrClose={ ( block ) => {
if ( block ) {
const insertedBlockTitle = getBlockDisplayTitle( block );
speak( sprintf( __( '%s block inserted' ), insertedBlockTitle), 'assertive' );
}
} )
It looks like it's all down to the fact that the only way to get the de-facto block title is using a react hook, when really it should be possible using a simple function call (getBlockDisplayTitle( block )
or similar), so that means introducing more hooks.
It's not straightforward to solve unfortunately, but might be something to think about if we keep hitting this problem.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. The process of getting the block title is very hook dependant. Would need to decouple all that first.
return { | ||
hideInserter: | ||
!! getTemplateLock( clientId ) || | ||
__unstableGetEditorMode() === 'zoom-out', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the need for __unstableGetEditorMode() === 'zoom-out'
?
It stands out, because zoom out mode is something that applies to the editor canvas, and List View is separate to the editor canvas, so I'm wondering how the two might be linked.
It looks like it isn't possible to access List view in zoomed out mode (though it does stay open when already open, which seems like a bug).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks to me like it's copy/pasted from packages/block-editor/src/components/block-list-appender/index.js. Maybe there's some benefit to keeping these files in sync where possible even though this line isn't needed, with the hope that we can share more code in the future?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would probably lean towards removing it, but it's not critical and definitely not a blocker.
packages/edit-site/src/components/secondary-sidebar/list-view-sidebar.js
Outdated
Show resolved
Hide resolved
Co-authored-by: Daniel Richards <[email protected]>
Co-authored-by: Daniel Richards <[email protected]>
Co-authored-by: Daniel Richards <[email protected]>
I gave this another re-review, and it looks like the one remaining thing is to move the appender styles across from off canvas to list view, when that's done this should be good to go 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚢
What?
This adds a private
showAppender
prop to the list view component.Fixes #46992,
Why?
This is a step towards being able to reuse this component in the Navigation block inspector controls, and retiring the OffCanvasEditor component.
How?
showAppender
propertyListView
component to `PrivateListViewPrivateListView
component with a new component which always setsshowAppender
to false.Testing Instructions
git checkout add/appender-to-list-view
/packages/edit-site/src/components/secondary-sidebar/list-view-sidebar.js
<ListView />
.<ListView showAppender={ true } />
.Testing Instructions for Keyboard
To open the block inserter in the list view, you can tab to it, once you have opened the list view.
Screenshots or screencast