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] update inputProps documentation #3037

Closed
tbalsys opened this issue Oct 15, 2018 · 8 comments · Fixed by #3161
Closed

[select] update inputProps documentation #3037

tbalsys opened this issue Oct 15, 2018 · 8 comments · Fixed by #3161

Comments

@tbalsys
Copy link

tbalsys commented Oct 15, 2018

Prop inputProps in components Select and Suggest doesn't work.

Environment

  • @blueprintjs/select 3.2.0
  • Chromium 69.0.3497.100 (Official Build) Arch Linux (64-bit)

Steps to reproduce

<Suggest
  items={Films.TOP_100_FILMS}
  itemRenderer={renderFilm}
  inputValueRenderer={film => film.title}
  onItemSelect={this.handleValueChange}
  noResults={<MenuItem disabled text="No results." />}
  inputProps={{ value: query, onChange: this.handleChange }}
>
  <Button text={buttonText} rightIcon="caret-down" />
</Suggest>

Actual behavior

Method this.handleChange gets never executed.

Expected behavior

Providing prop inputProps should make component controlled.

Possible solution

In suggest.tsx in method renderQueryList:

                <InputGroup
                    {...inputProps}
                    placeholder={isOpen && selectedItemText ? selectedItemText : placeholder}
                    inputRef={this.refHandlers.input}
                    onChange={listProps.handleQueryChange}
                    onFocus={this.handleInputFocus}
                    onKeyDown={this.getTargetKeyDownHandler(handleKeyDown)}
                    onKeyUp={this.getTargetKeyUpHandler(handleKeyUp)}
                    value={isOpen ? listProps.query : selectedItemText}
                />

{...inputProps} should be moved to the end, so that it overrides value and onChange props.

@giladgray
Copy link
Contributor

@tomaszbalsys this is by design and mentioned in the docs:
image

@tbalsys
Copy link
Author

tbalsys commented Oct 17, 2018

@giladgray Thank you for your answer. In that case the documentation needs to be updated.

https://blueprintjs.com/docs/#select/select-component:
screenshot from 2018-10-17 20-52-14

https://blueprintjs.com/docs/#select/suggest:
screenshot from 2018-10-17 20-50-33

@giladgray
Copy link
Contributor

ah fair enough.

@giladgray giladgray reopened this Oct 17, 2018
@giladgray giladgray changed the title inputProps doesn't work update inputProps documentation Oct 17, 2018
@giladgray giladgray changed the title update inputProps documentation [select] update inputProps documentation Oct 17, 2018
@tbalsys
Copy link
Author

tbalsys commented Oct 17, 2018

Another issue is that onQueryChange gets executed 3 times for one keypress.

In queryList.tsx:

  1. handleQueryChangesetQueryonQueryChange
  2. handleQueryChangeonQueryChange
  3. componentWillReceivePropssetQueryonQueryChange

I created the component like this:

        <Suggest
          items={Films.TOP_100_FILMS}
          itemRenderer={renderFilm}
          inputValueRenderer={film => film.title}
          onItemSelect={this.handleValueChange}
          query={query}
          onQueryChange={this.handleChange}
        >
          <Button text={buttonText} rightIcon="caret-down" />
        </Suggest>

@giladgray
Copy link
Contributor

giladgray commented Oct 17, 2018

@tomaszbalsys please do not conflate this issue with others. file a separate issue for separate concerns.

edit: but it looks like you want #2983

@EchoZhaoH
Copy link

EchoZhaoH commented Nov 5, 2018

@giladgray Is this a bug? Are you ready to fix it?

@giladgray
Copy link
Contributor

@EchoZW i'm certainly ready for it to be fixed!

@EchoZhaoH
Copy link

@giladgray Excuse me, when are you going to fix this problem?
and I think you should add a bug label to this issue.

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