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

[Search] extern search input #359

Open
3 tasks done
artmarks opened this issue Sep 12, 2024 · 1 comment
Open
3 tasks done

[Search] extern search input #359

artmarks opened this issue Sep 12, 2024 · 1 comment

Comments

@artmarks
Copy link
Contributor

Issue description

Issue description

I would like to use the search-component with an extern search value. In our example the search term will come as url-parameter from another component. In our case the first result of the search, should be choosen and trigger the onSelect function as usual.

Discussion

We can implement the feature but there seem to be multple options for the general use case, that should be discussed:

  • If there is just a single result:
    • Just trigger onSelect for this
  • If there are multple results:
    • Just take the first result of the search and trigger onSelect
    • Do nothing
    • Show a warning
    • Show a warning, but still use the first result
    • Modify SearchSelectEvent and return an Array of SearchResult with onSelect
  • If there is no result:
    • Do nothing
    • Show a warning
    • Modify SearchSelectEvent and let SearchResult be null or an empty Array

And maybe there is an other case, that i didn't think of :)

I think modifying SearchSelectEvent to an SearchResult-Array would give the developer the most freedom, but would also be a breaking change.

Validations

@arnevogt
Copy link
Member

We have the same requirement for another project.

Here are my thoughts:
I am not sure if we should trigger onSelect automatically since generally we don't know what the expected behavior might be.
Instead I would introduce onSearchCompleted which provides the search results and the developer can use it as it is desired.

Alternatively we could even introduce onSearchStateChanged => (searchState: FullSearchState) => void;.
Then the developer could react on every change. That would basically supersede the existing onSelect (and onInputChanged that we might introduce). But I think this would

  • be a big change to the current API
  • trigger many events (e.g. every time the user types in a single character) that might be hard to handle for the developer.

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

No branches or pull requests

2 participants