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

[EuiSelectableTemplateSitewide] should allow for customizing the searchValue #4277

Closed
myasonik opened this issue Nov 17, 2020 · 2 comments · Fixed by #4305
Closed

[EuiSelectableTemplateSitewide] should allow for customizing the searchValue #4277

myasonik opened this issue Nov 17, 2020 · 2 comments · Fixed by #4305

Comments

@myasonik
Copy link
Contributor

myasonik commented Nov 17, 2020

In Kibana, we're adding some advance search options to our global search bar. (elastic/kibana#74290)

No UI changes, just allowing for some basic query syntax.

Trying to make these changes uncovers two problems:

  1. EuiSelectable always does its own filtering. This wasn't a problem before when the API was returning results that had a string match to the value so the filtering just returned everything back but with query syntax in the mix, EUI's string match filtering breaks down. This can be mostly turned off by passing in onSearch: () => {} into searchProps but a filter EUI-side technically does still happen on componentDidMount which, though isn't an issue for Kibana now, is still not really desired.

    Proposed solution: add a boolean flag which controls whether or not EUI filters options (flag name totally up in the air, maybe optionFiltering?).

    Alternative: key off of whether or not onSearch is passed in and use that as a de facto flag for the above (i.e., if onSearch is passed in, disable EUI-side filtering).

  2. Using the onSearch workaround mentioned above, the rendered options lose the ability to highlight the searchValue because searchValue as EuiSelectable understands it is no longer correct.

    Proposed solution: Allow passing in a searchValue which will get used in the rendered options for highlighting. (Actually, just implementing this could let us not disable the filtering happening above. This way, basically forcing results to have some representation that can be highlighted from the search value which is probably a good thing.) @cchaos did I understand from the EUI meeting that this is your preferred way forward?

    Alternative: If EUI exported euiSelectableTemplateSitewideRenderOptions then Kibana could use it as the renderOption but pass in any searchValue it wants.

CC @chandlerprall @ryankeairns @pgayvallet

I can start on a PR once I understand what the preferred way forward is.

@pgayvallet
Copy link

pgayvallet commented Nov 17, 2020

Both proposed solutions sound good regarding the navigational search needs.

@joshdover
Copy link
Contributor

Disclaimer: I'm not very familiar with this code in EUI.

It appears that getMatchingOptions already supports a isPreFiltered argument, but there's no way to specify this value from the consuming side. Could we add a isPreFiltered prop to selectable and pass it in here? https://github.com/elastic/eui/blob/master/src/components/selectable/selectable.tsx#L193

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants