-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Nav Block - show recent pages as default suggestions when creating Na…
…v Links (#19458) * Adds ability to manual trigger search data fetch * Update to prop to experimental and rename to initialSuggestions * Query for and display 5 most recently modified Pages * Update initial suggestions to be display whenever the input is empty and there are no current suggestions This is needed to ensure that the async fulfillment of the initialSuggestions prop causes the component to re-render and display the initial suggestions. Without this the initial suggestions would only be available if the prop is fufilled on the initial component mount. * Fix to ensure initial suggestions are shown when pages request fulfills Addresses issues noted in #19458 (comment) * Updates to display 3 most recently modified pages instead of 5 Addresses #19458 (comment) * Fix to allow keyboard arrow to move focus into suggestions when present Previously it was not possible to use the down arrow key to move the focus into the search suggestions when initialSuggestions were displayed. This was due to requirement for there to be a value in the `input` which is now no longer valid now that initial suggestions can be displayed. Note that removing the derived setting of selectedSuggestion state is valid as selectedSuggestions are always reset on each new data fetch anyway. Resolves issue noted in #19458 (comment) * Fix bug whereby not providing initialSuggestions to LinkControl disabled the ability to search at all Test failures led to uncovering of a bug whereby the URLInput component’s `updateSuggestions` method would exit early it initialSuggestions wasn’t provided. As initialSuggestions is an optional prop this means that all fetching of search suggestions was disabled if the initialSuggestions wasn’t provided. Fixed this bug and all tests by improving the conditionals. * Adds tests to cover displaying initial suggestions * Removes redundant const comment * Test fix to e2e tests * Try looser mock request matching to fix e2e test failures * Try fix Travis e2e test failure by clearing request mocks * Fix not awaiting mock setup * Fix inadvertant revert of e2e test fix * Refactor to remove seperate initialSuggestions query 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) * Refactor to use empty value as condition for initialSuggestions request Addresses #19458 (comment) * Fix “suggestions” typo * Update to reuse existing edit constant * Fix initial suggestions showing when input has value * Fix potential infinite render using flag to conditionalise updating suggestions on update or mount * Add test to cover inifinite re-render loop. * Fixes typo in WordPress ORG link in e2e tests * Fix e2e test failure due to console warning in LinkControl This is a temp fix and I’ve raised an Issue to solve the core issue which will then make this fix redundant. #19634 * Revise snapshots * Restore missing `fetchSearchSuggestions` prop following rebase * Fix lint indentation error * Rename prop * Fix test broken due to prop rename
- Loading branch information
Showing
10 changed files
with
185 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.