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

[select] Select component doesn't respect the query prop #4362

Open
cemreyavuz opened this issue Oct 7, 2020 · 3 comments · May be fixed by #4363
Open

[select] Select component doesn't respect the query prop #4362

cemreyavuz opened this issue Oct 7, 2020 · 3 comments · May be fixed by #4363

Comments

@cemreyavuz
Copy link
Contributor

cemreyavuz commented Oct 7, 2020

Environment

  • Package version(s): @blueprintjs/select (3.14.2)
  • Operating System: Windows Version 10.0.18363 Build 18363
  • Browser name and version: Google Chrome 85.0.4183.121

Code Sandbox

https://codesandbox.io/s/select-component-doesnt-respect-query-prop-dlih7

Steps to reproduce

  1. Import the Select component from @blueprintjs/select and render
  2. Pass the query prop to a Select component
  3. Click the rendered Select component and update the text input

Actual behavior

Text input is updated.

Expected behavior

As mentioned in the documentation of Select component, the expected behavior is that the text input is not changed and controlled via query prop.

inputProps
Props to spread to the query InputGroup. Use query and onQueryChange instead of inputProps.value and inputProps.onChange to control this input.

Possible solution

Updating line 134 in select.tsx from:

value={listProps.query}

to this:

value={this.props.query || listProps.query}

solves the problem. It seems like the query prop is never directly passed to the input group. QueryList component is the one who controls the query of InputGroup in Select component. It initializes its internal query state with the query prop, but from that point onward, it doesn't respect the query prop of Select component and send its internal state to InputGroup.

@adidahiya
Copy link
Contributor

adidahiya commented Oct 21, 2020

What exactly is the problem in your code sandbox? It seems like the query prop control is working as intended.

I briefly traced through the rendering stack of Select / QueryList and it looks like listProps.query is being set to QueryList's state.query (which is kept up to date via QueryList's componentDidUpdate) here:

... which means we achieve the same effect as referencing this.props.query as you've suggested.

are you able to produce a failing unit test you could perhaps work with?

@nickensoul
Copy link

Screen.Recording.2021-06-16.at.17.42.09.mov

@adidahiya in the screencast attached, there should not be any other values in the input other than "constant query" after changing event

@adidahiya
Copy link
Contributor

@nickensoul does #4363 fix the issue from your screen recording?

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