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

[Suggest] refactor to support new QueryList state #2748

Merged
merged 5 commits into from
Aug 1, 2018

Conversation

giladgray
Copy link
Contributor

Targets #2747

Changes proposed in this pull request:

  • refactor Suggest to support new QueryList state and un/controlled features.
  • ⭐️ Suggest now shows the selected item as the placeholder text when editing.
    • this provides a much nicer experience as it doesn't mess with your typing, and the code is oh so much simpler!
    • I was able to remove an entire state field isTyping, which was responsible for inconsistent behavior in the common test suites.
  • revert disabled tests and fix esc/tab tests.
  • add resetOnSelect switch to example

Gilad Gray added 4 commits July 31, 2018 18:26
also remove isTyping state, which fixes double render.
when open, selectedItem appears in placeholder instead of input value.
this is a nicer experience and works great with resetOnSelect.
these keys used to clear the selection, now they just cancel a selection in progress and keep the previous selection state.
@blueprint-bot
Copy link

fix esc/tab tests

Preview: documentation | landing | table

Copy link
Contributor

@themadcreator themadcreator left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question about the ternary, otherwise cool

>
<InputGroup
placeholder="Search..."
value={inputValue}
placeholder={isOpen && selectedItemText ? selectedItemText : "Search..."}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"", which you set as the default on line 110 is falsy. is that what you intend?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes it should say "Search..." instead of ""

@blueprint-bot
Copy link

default placeholder

Preview: documentation | landing | table

@giladgray giladgray merged commit f05007a into gg/reset-on-select Aug 1, 2018
@giladgray giladgray deleted the gg/reset-on-suggest branch August 1, 2018 22:50
giladgray added a commit that referenced this pull request Aug 1, 2018
* move resetOnSelect to IListItemsProps so all components share it

* ⭐ allow activeItem and query to be un/controlled

move required props from IQueryListProps to optional in IListItemsProps!
add handleQueryChange to renderer props.
move activeItem/query state into IQueryListState

* QueryList initialize state and update renderer usage

* refactor QueryList to control activeItem and query and always pick an enabled first item

* refactor four friends to push state into QueryList

* little fixes

* common suite of tests for select components

* update docs: no value/onChange in inputProps

* tzp tests

* only invoke onQueryChange if it changed

* revert Suggest (followup PR with more extensive changes)

* [Suggest] refactor to support new QueryList state (#2748)

* refactor Suggest to use QueryList's activeItem and query

also remove isTyping state, which fixes double render.
when open, selectedItem appears in placeholder instead of input value.
this is a nicer experience and works great with resetOnSelect.

* add resetOnSelect switch to Suggest example

* revert disabled tests

* fix esc/tab tests

these keys used to clear the selection, now they just cancel a selection in progress and keep the previous selection state.

* default placeholder

* remove omnibar query prop (semantic conflict)

* activeItem: T | null

- explicit null for "no active item"
- undefined optional prop puts it in uncontrolled mode

* maybeRenderClearButton
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

Successfully merging this pull request may close these issues.

3 participants