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

fix(queryHook): restore behaviour of queryHook #4202

Merged
merged 8 commits into from
Nov 26, 2019

Conversation

tkrugg
Copy link
Contributor

@tkrugg tkrugg commented Nov 20, 2019

Summary

There has been many complaints from user on our debouncing guide no longer working as expected.

This issue was introduced when the SearchBox component was converted into a Preact, and the following condition removed:
c073a9a#diff-530222e0c4597f2110dc6ba173a306b0L98

  • Before SearchBox refactor:

    • when input was focused, the query exposed by the connector didn't update the input value
    • when input was not focused, the query exposed by the connector did update the input value
  • After SearchBox refactor:

    • regardless on whether input was focused, the query exposed by the connector updates the input value

This PR restores the logic as found before the refactor.

Result

fixes #4141

How to test this:

Before

2019-11-20 13 23 56

After
2019-11-20 13 20 29

There has been many complaints from user on our [debouncing guide](https://www.algolia.com/doc/guides/building-search-ui/going-further/improve-performance/js/#debouncing) no longer working as expected.

This issue was introduced when the SearchBox component was converted into a Preact, and the following condition removed:
c073a9a#diff-530222e0c4597f2110dc6ba173a306b0L98

**Before SearchBox refactor**:
- when input was focused, the query exposed by the connector didn't update the input value
- when input was not focused, the query exposed by the connector did update the input value

**After SearchBox refactor**:
- regardless on whether input was focused, the query exposed by the connector updates the input value

This PR restores the logic as found before the refactor.

fixes #4141
Copy link
Contributor

@Haroenv Haroenv left a comment

Choose a reason for hiding this comment

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

(approve is for the fix, tests still need to be passing)

src/components/SearchBox/SearchBox.js Show resolved Hide resolved
src/components/SearchBox/SearchBox.js Show resolved Hide resolved
tkrugg added a commit to algolia/instantsearch-e2e-tests that referenced this pull request Nov 21, 2019
In React and Preact the CLEAR selenium instruction does not fire any event, and therefore does not update the component's internal state (see this job for example: https://app.saucelabs.com/tests/4518f96fdfd447e998786d0ff463658a#54)

It is equivalent to `input.value = ''`.

There are multiple sources reporting a similar behaviour (see SeleniumHQ/selenium#6741)

Since this change: algolia/instantsearch#4202

```jsx
<input value={state.query} />
```

instead of

```jsx
<input value={props.query} />
```

Since binding the input value to a `state.query` (rather than a `props.query`), it appears the click we use to focus on the searchbox re-syncs `input.value` with `state.query`.
Copy link
Member

@francoischalifour francoischalifour left a comment

Choose a reason for hiding this comment

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

Nice to see this fixed!

I originally omitted the focused condition simply because I though that was some legacy code that didn't have effect anymore... And it was merged like that. All that to say that we should definitely document in the code why we need to check for the focused state; this solution is not trivial to grasp.

tkrugg added a commit to algolia/instantsearch-e2e-tests that referenced this pull request Nov 26, 2019
* fix(setSearchBoxValue): reset searchbox before editing

In React and Preact the CLEAR selenium instruction does not fire any event, and therefore does not update the component's internal state (see this job for example: https://app.saucelabs.com/tests/4518f96fdfd447e998786d0ff463658a#54)

It is equivalent to `input.value = ''`.

There are multiple sources reporting a similar behaviour (see SeleniumHQ/selenium#6741)

Since this change: algolia/instantsearch#4202

```jsx
<input value={state.query} />
```

instead of

```jsx
<input value={props.query} />
```

Since binding the input value to a `state.query` (rather than a `props.query`), it appears the click we use to focus on the searchbox re-syncs `input.value` with `state.query`.
Copy link
Contributor

@Haroenv Haroenv left a comment

Choose a reason for hiding this comment

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

+1 once e2e tests pass

@tkrugg tkrugg merged commit 75602ca into develop Nov 26, 2019
@tkrugg tkrugg deleted the fix/restore-queryHook-behaviour branch November 26, 2019 13:09
tkrugg added a commit that referenced this pull request Nov 26, 2019
* fix(queryHook): restore behaviour of queryHook

There has been many complaints from user on our [debouncing guide](https://www.algolia.com/doc/guides/building-search-ui/going-further/improve-performance/js/#debouncing) no longer working as expected.

This issue was introduced when the SearchBox component was converted into a Preact, and the following condition removed:
c073a9a#diff-530222e0c4597f2110dc6ba173a306b0L98

**Before SearchBox refactor**:
- when input was focused, the query exposed by the connector didn't update the input value
- when input was not focused, the query exposed by the connector did update the input value

**After SearchBox refactor**:
- regardless on whether input was focused, the query exposed by the connector updates the input value

This PR restores the logic as found before the refactor.

fixes #4141

* chore: update snapshots

* fix: reset works again

* add a comment explaining the bahviour of the widget on focus

* add variable names to comment

* chore: update e2e tests

* add comment explaining test puropose
Haroenv added a commit that referenced this pull request Nov 28, 2019
## [4.0.1](v4.0.0...v4.0.1) (2019-11-28)

### Bug Fixes

* widget name in documentation link for index ([#4172](#4172)) ([fe7e588](fe7e588))
* **helper:** rely on stable version of algoliasearch-helper ([#4200](#4200)) ([ff11731](ff11731))
* **infiniteHits:** correct widget options types ([#4222](#4222)) ([bb1b327](bb1b327))
* **queryHook:** restore behaviour of queryHook ([#4202](#4202)) ([7bf96cb](7bf96cb)), closes [/github.com/algolia/instantsearch.js/commit/c073a9acb51fff3c15278fcd563e47fec55c8365#diff-530222e0c4597f2110dc6ba173a306b0L98](https://github.com//github.com/algolia/instantsearch.js/commit/c073a9acb51fff3c15278fcd563e47fec55c8365/issues/diff-530222e0c4597f2110dc6ba173a306b0L98)

### Features

* **transformers:** add tests ([#4153](#4153)) ([5a28415](5a28415))
Haroenv pushed a commit that referenced this pull request Nov 23, 2022
* fix(setSearchBoxValue): reset searchbox before editing

In React and Preact the CLEAR selenium instruction does not fire any event, and therefore does not update the component's internal state (see this job for example: https://app.saucelabs.com/tests/4518f96fdfd447e998786d0ff463658a#54)

It is equivalent to `input.value = ''`.

There are multiple sources reporting a similar behaviour (see SeleniumHQ/selenium#6741)

Since this change: #4202

```jsx
<input value={state.query} />
```

instead of

```jsx
<input value={props.query} />
```

Since binding the input value to a `state.query` (rather than a `props.query`), it appears the click we use to focus on the searchbox re-syncs `input.value` with `state.query`.
Haroenv pushed a commit that referenced this pull request Nov 24, 2022
…ntsearch-e2e-tests#15)

* fix(setSearchBoxValue): reset searchbox before editing

In React and Preact the CLEAR selenium instruction does not fire any event, and therefore does not update the component's internal state (see this job for example: https://app.saucelabs.com/tests/4518f96fdfd447e998786d0ff463658a#54)

It is equivalent to `input.value = ''`.

There are multiple sources reporting a similar behaviour (see SeleniumHQ/selenium#6741)

Since this change: #4202

```jsx
<input value={state.query} />
```

instead of

```jsx
<input value={props.query} />
```

Since binding the input value to a `state.query` (rather than a `props.query`), it appears the click we use to focus on the searchbox re-syncs `input.value` with `state.query`.
Haroenv pushed a commit that referenced this pull request Nov 24, 2022
…ntsearch-e2e-tests#15)

* fix(setSearchBoxValue): reset searchbox before editing

In React and Preact the CLEAR selenium instruction does not fire any event, and therefore does not update the component's internal state (see this job for example: https://app.saucelabs.com/tests/4518f96fdfd447e998786d0ff463658a#54)

It is equivalent to `input.value = ''`.

There are multiple sources reporting a similar behaviour (see SeleniumHQ/selenium#6741)

Since this change: #4202

```jsx
<input value={state.query} />
```

instead of

```jsx
<input value={props.query} />
```

Since binding the input value to a `state.query` (rather than a `props.query`), it appears the click we use to focus on the searchbox re-syncs `input.value` with `state.query`.
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.

queryHook is broken
3 participants