-
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
Nav Block - enable page creation from within Block #19775
Conversation
Question:In this implementation you cannot use the arrow to move to the Is this valid a11y wise? My concern is that the If we want to promote the |
Note: in order to make this PR work we're going to need:
Will tackle this tomorrow. |
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.
Noticed some inconsistencies and problems building up. We should look to tackle these before they become any more "baked in" @marekhrabe.
packages/block-editor/src/components/link-control/search-create-button.js
Outdated
Show resolved
Hide resolved
packages/block-editor/src/components/link-control/search-create-button.js
Outdated
Show resolved
Hide resolved
37d322c
to
49f0b2e
Compare
@aduth I rebased this branch and found a tonne of conflicts as a result of your refactoring of If you have time to glance at the rebased file in this branch I'd feel a lot more confident knowing the rebase hadn't nuked any of your changes. |
I can plan to take a look in my morning. Are you otherwise expecting this to be review ready? |
Thanks (with caveat below).
No. Actually there is a bug whereby hitting Maybe best wait until that's fixed. That said, weren't you looking at the handling of form |
What I was working on with regards to the submission is already merged, so if there's an issue, it's not one I'd be aware of or am actively working on. See: #19651 |
d98b989
to
6882363
Compare
This was a throw back to a previous state of the `LinkControl` component whereby we wanted to render a create option to allow the user to create blank pages. This was removed as a requirement but the component was not fixed to account for that. Addresses: #19775 (comment)
Build failures are due to a known |
Previously the code to handle the async flow including error handling was duplicated across two handler props. Consolidating helps DRY things and avoid accidental errors being introduced. Addresses #19775 (comment)
… if provided. Addresses #19775 (comment)
I will merge this shortly following 👍 from @obenland. |
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.
Did a final smoke test with admin, editor, and author roles and everything works as expected.
Really nice work @getdave, thank you for your persistence! Also thanks to @marekhrabe, @jeryj, and @aduth for your tremendous help.
Ok that's all folks. It's merged! |
Closes #18900
This PR aims to allow users to create new Pages (only) on the fly from within the Navigation Block.
A Note on coupling with WordPress
Note that the
LinkControl
is within the Block Editor which is supposed to be "unaware" of WordPress. That said the existing implementation inmaster
is already coupled to WordPress viaURLInput
which requests data from WP endpoints. Therefore we're following existing precedent here by introducing a prop to pass a handler function create entities on the fly. This is entirely optional and can be configured by the developer so it is less coupled to WP than you might imagine. There is a concept of "creating something" but that's it. We feel this is a good compromise.Testing Instructions
Dashboard > Pages
Other testing scenarios
Todo
Consider using
core/data
to create the Pages rather than manualapiFetch
.Fix to ensure Create Page option is displayed if the entry contains spaces (eg:
This is a Test
).Implement error handling for when Page cannot be created or times-out.
Implement handling when Page already exists. Perhaps when attempting to create a page which already exists, it seamlessly reuses the existing Page without any need for erroring.@marekhrabe and I decided that as per current WP convention a new page should be created with the entered title but with a different slug (eg:new-page-2
).Handle a11y concerns regarding the "Create" option not being a valid suggestion which you can move to via the Arrow keys.
Avoid showing the option to create pages when user doesn't have the capability (
wp.data.select('core').canUser('create', 'pages')
)Ensure entity (aka Page creation) is possible using keyboard.
Implement checks against failure
saveEntityRecord
result types and alsoentry
results which are missing appropriate values. This is needed in Nav Link Blockedit
createEntity()
definition.Avoid suggesting URLs for input that isn't a valid URL. This may be better handled in a separate PR as having both options isn't causing any regression. Waiting on URL: Conform to URL Living Standard definition of valid URL #19871.
Add "Loading" spinner Icon to
isResolving
state when creating a Page (@jeryj ) - see Navigation: Add option to create a new page #18900 (comment)Ensure Error notice has correct spacing as per Design (@jeryj ).
Fix failing e2e tests due to use of
uniqueId
invalidating the snapshots. Check with @aduth that usinguniqueId
is a good idea. (@jeryj ).Solve creation of unique IDs for the x2 manually created suggestion types.
Resolve suggestions label a11y issue (@jeryj).
Fix additional unwanted spacing below input when no search results. See here. (@jeryj)
Write e2e test for Nav Block to cover creating Pages from within Block.
Update color references to Sass vars in consultation with Designer (@jeryj )
Fix component possibly unmounted when state change occurs issue.
How has this been tested?
Unit tests. Manual tests.
Screenshots
Types of changes
New feature (non-breaking change which adds functionality)
Checklist: