-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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 - show recent pages as default suggestions when creating Nav Links #19458
Nav Block - show recent pages as default suggestions when creating Nav Links #19458
Conversation
Pinging @youknowriad because I know he's concerned about ongoing changes to |
I wonder if 5 items is too many. With the way things fade out, it looks a little awkward. Maybe 3 suggestions would help clean up the default view of this popover, making it visually simpler by default. |
I much prefer this implementation to the empty state. Nice work, @getdave! Here are the few things I found during my functional review. The first and second likely the only one that seems worth addressing within this PR. Always update text from selected link?When selecting a new suggestion off of a page that already has text, I think the text should default to being replaced by the selected title. Currently it remains the same. I can see how this would be maybe be preferable if they entered custom content, but I think it's probably more likely they just want the text replaced. Keyboard navigation?At the moment there is no way (that I saw) to access the pages list via the keyboard. The tab key cycles between the input and the X to clear the link. First initialization of empty menu doesn't show the recommended linksI'm not sure what is causing this one, but the initialization of an empty menu on a new page doesn't show the pages list. Any subsequent ones show the list. If the page already has a nav block, it also shows the list fine. It appears to only occur on the first initialization and then the auto-opening of the link field. Account for items already in the menu?This isn't necessarily an issue, but do we want to handle the suggestions based on what items are already in the menu? The most recently published items are already within the menu in this screenshot. |
@shaunandrews I've updated to 3 as suggested (see updated screencapture in PR desc) |
@jeryj Thanks for the review.
Nice catch. This was a bug in my implementation. I've resolved this and you can see it working in the screencapture in the PR desc.
Another great catch. I've also fixed this but I'd appreciate you confirming via a manual test. Thanks.
I think this is a good point but not for this PR. Would it be possible for you to raise an Issue and then we can discuss the desired behaviour?
We don't but we could...I'm thinking maybe in a followup PR so as not to block the basic working implementation but I could be persuaded... |
I've broken the tests. Am going to look at this tomorrow. |
I had a good test of this. I think having the recent pages there is a good addition. Plus one to @jeryj's feedback above. I think this could merge as it exists because it works well, however I've opened another issue with some visual improvements that I think should be discussed and iterated on as a follow up: |
As per the GH thread below, this refactors the code to avoid the need to introduce a new fetch API around `__experimentalInitialSuggestions`. Now instead we simply reuse the existing fetchSuggestions handler to get the initial results. The only different being we introduce an arguments object to queries to restrict the number of results displayed for initial Suggestions. See #19458 (comment)
…uggestions on update or mount
This is a temp fix and I’ve raised an Issue to solve the core issue which will then make this fix redundant. #19634
f66fadc
to
259938a
Compare
I neglected to update the Nav Block to use the renamed |
const { keyCode } = event; | ||
|
||
event.stopPropagation(); | ||
|
||
if ( keyCode === ENTER ) { | ||
|
||
} |
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.
Were these changes intended to have been included? Looks like dead code to me.
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.
Dead code. Being removed elsewhere.
Description
Closes #18899.
When first creating a Nav Link ("item") Block the hyperlink UI presents a blank search field. To better serve the default use case of adding pages, this PR updates the implementation to display a list of the most recently created Pages.
This involves a refactor of the
URLInput
to add a new boolean propinitialSuggestions
which (internally)affords the ability to trigger rendering of search results without anything being entered into the(for more on this see the original Issue) triggers a call for default search results when the input field is empty.<input>
fieldHow has this been tested?
Screencapture
Types of changes
New feature (non-breaking change which adds functionality).
Checklist: