-
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
Fix: Inserter on the navigation sidebar. (#48049 #48049
Fix: Inserter on the navigation sidebar. (#48049 #48049
Conversation
Size Change: +1.99 kB (0%) Total Size: 1.33 MB
ℹ️ View Unchanged
|
Flaky tests detected in d96da60. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/4241952442
|
It seems to me the off canvas editor shouldn't be assuming that the menu is selected. Can't we instead update the logic within the off canvas editor instead of adding a new inserter and hiding the built-in one? |
I think the same as Riad - let's try to not need to hide via CSS the elements but instead make the thing better at composing different parts. |
55a71ae
to
4b61df1
Compare
a433b4f
to
be1cf88
Compare
3000cc0
to
ff7ad9d
Compare
Hi @youknowriad, @draganescu, this PR was updated. Now, it updates the OffSiteNavigationEditor. Visually things look like this: The same as before. |
4b61df1
to
30afe97
Compare
ff7ad9d
to
761e037
Compare
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 looks good to me, I'd appreciate a review from folks working on the off canvas editor cc @draganescu
// Only show the appender at the first level. | ||
const showAppender = level === 1; | ||
// Only show the appender at the first level and if there is a parent block. | ||
const showAppender = level === 1 && parentId; |
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 does this addition do?
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.
If there is no parentId, we don't show the appender. The case where we may not have a parentId is if for example, we don't have navigation menus on the page the sidebar shows the offsite navigation editor which says correctly navigation is empty but without this change shows an appender that adds things to the root which is unexpected.
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 understand. Ok it's a good guard, but we should never be in this situation:
we don't have navigation menus on the page
I think the navigation is not empty just because the current page is not showing it. This is tricky and outside the scope of this PR but, what if the page with no navigation block is linked in the navigation, clicking on it in the sidebar would then hide the navigation from the sidebar - quite unexpected.
@@ -227,6 +232,7 @@ function OffCanvasEditor( | |||
> | |||
<ListViewContext.Provider value={ contextValue }> | |||
<ListViewBranch | |||
parentId={ parentId } |
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.
is a better name for this rootBlockId or something as the list view is not really a child of a block?
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.
The component ListViewBranch already had the parentId property, I'm just passing the property in a case where we were not passing it before, but the prop already existed.
The list view component also calls it parentId
parentId, |
I can change it to rootBlockId on the offsite canvas editor and the list view if you prefer. I don't have a specific preference.
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.
Oh I lost this fact in reviewing the code, thought we just added parentId
. Let's not change anything then :)
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 is in a good shape 👏🏻
Squashed commits: [b429410eea] Fix: Inserter on navigation menu sidebar.
761e037
to
d96da60
Compare
With the changes on #47853, we are not using a specific block editor for the navigation sidebar anymore. The inserter of the off-canvas menu editor assumes the navigation block or a child is selected. On the navigation sidebar, the navigation block may not be selected, so we need a specific inserter for the navigation sidebar.
This PR adds a simple inserter for the navigation sidebar. Given that we previously wanted to have the text "Add menu item" this PR also adds the text to the inserter superseding PR #46949.
Testing
Verify the navigation sidebar works as expected.