Skip to content
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: Editing a link should show search results #19647

Closed
apeatling opened this issue Jan 14, 2020 · 8 comments · Fixed by #19850
Closed

Nav Block: Editing a link should show search results #19647

apeatling opened this issue Jan 14, 2020 · 8 comments · Fixed by #19850
Labels
[Block] Navigation Affects the Navigation Block [Status] In Progress Tracking issues with work in progress [Type] Bug An existing feature does not function as intended

Comments

@apeatling
Copy link
Contributor

Describe the bug
When I edit a navigation link I only see the search term in the box, I don't see any search results so I can select something different. Only when I edit the search term do I see search results.

See this gif for an example:

2020-01-14 12 02 02

To reproduce
Steps to reproduce the behavior:

  1. Select a navigation link in the navigation block
  2. Select the "Link" menu
  3. Click the "Edit" button on the popup
  4. See the link inserter with the link text in the search box, but no results
  5. Edit the link text in the search box to see results

Expected behavior
I should see search results as soon as I hit the "Edit" button. I might have selected the wrong page or post and want to choose a different result.

@apeatling apeatling added [Type] Bug An existing feature does not function as intended [Block] Navigation Affects the Navigation Block labels Jan 14, 2020
@getdave
Copy link
Contributor

getdave commented Jan 20, 2020

May require changes to LinkControl and/or (the underlying) URLInput.

@getdave
Copy link
Contributor

getdave commented Jan 23, 2020

This will be tricky because triggering of fetching search results is controlled by the inner mechanics of the underlying URLInput component. There is no way to programmatically trigger this fetching. It is triggered by:

  1. onChange in the <input />
  2. When there is no value (to show initialSuggestions).

I was thinking we might be able to just try always triggering updateSuggestions on each componentDidUpdate but only if

  1. this.isUpdatingSuggestions is not set
  2. <input /> has a value with length which is no empty whitespace.

We'd need to be careful though cos then we'd need to avoid calling updateSuggestions in the this.onChange method..

Would need careful unit and manual testing to avoid infinite loops.

@getdave
Copy link
Contributor

getdave commented Jan 23, 2020

Also worth noting that this implementation may all change due to this discussion #18061. However, that looks someway down the road.

@WunderBart
Copy link
Member

It is triggered by: 1. onChange in the

If the seach is triggered onChange, could it also be triggered (and handled by the same handler) onFocus?

Somewhere between these lines, like this:

<input
  ...
  onChange={ this.onChange }
  onFocus={ this.onChange }
/>

@getdave @jeryj

@jeryj
Copy link
Contributor

jeryj commented Jan 23, 2020

@WunderBart That does seem to work fine in my testing. It maybe feels a little hacky to call the onChange with the onFocus, but it works surprisingly well for a one line change on a complicated component! Nice idea!

@jeryj
Copy link
Contributor

jeryj commented Jan 23, 2020

I think there's going to be more to do than simply triggering a search, as it searches for the URL and not the linked label/page if it's internal. This means, if you hit enter, it disconnects it from the internal page and considers it a plain link.

It seems this issue will take more than just triggering the suggestions based on the URL.

clicking url link changes the label

@github-actions github-actions bot added the [Status] In Progress Tracking issues with work in progress label Jan 23, 2020
@jeryj jeryj removed their assignment Jan 23, 2020
@getdave
Copy link
Contributor

getdave commented Jan 24, 2020

This is also causing a problem for me in #19775, as when an error is shown when Page Creation fails we need to reshow the search results and the Create button.

Screen Capture on 2020-01-24 at 11-27-09

@getdave
Copy link
Contributor

getdave commented Jan 24, 2020

@jeryj @WunderBart I have found a way around this on my PR. It's a bit of a hack though so we might need to see what the Core team think. Effectively what I'm doing is forcing the input to detect a new change. I'm doing this by resetting it to an empty string and then immediately setting it back again to the original value.

This works!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Navigation Affects the Navigation Block [Status] In Progress Tracking issues with work in progress [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants