Skip to content
This repository has been archived by the owner on Jan 4, 2023. It is now read-only.

fix(setSearchBoxValue): reset searchbox before editing #15

Merged
merged 2 commits into from
Nov 26, 2019

Conversation

tkrugg
Copy link
Contributor

@tkrugg tkrugg commented Nov 20, 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

<input value={state.query} />

instead of

<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.

Demonstration of the issue:

@tkrugg tkrugg changed the title Update setSearchBoxValue.ts fix(setSearchBoxValue): reset searchbox before editing Nov 20, 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`.
@tkrugg tkrugg force-pushed the reset-searchbox-before-setting-value branch from 2d232b3 to 3b531c6 Compare November 21, 2019 12:55
@tkrugg tkrugg marked this pull request as ready for review November 21, 2019 12:55
Copy link

@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.

Does this mean that since your PR in InstantSearch, you will no longer be able to set the value externally?

@tkrugg
Copy link
Contributor Author

tkrugg commented Nov 26, 2019

@Haroenv you were never able to, the component always worked in a controlled way.

Only the clear instruction of selenium uses input.value, the rest is actual typing and sends change events. Relevant part of webdriver.io codebase supporting this are: setValue, clearValue, elementClear, addValue, elementSendKeys, elementSendKeys spec in JSON Wire Protocol.

  • When the value was bound to props.query there was a window where one could change input.value. Our e2e test took advantage of this.
  • With value being bound now to state.query that window is much smaller. Our e2e could .value="" but as soon as we focused on the element, the value was synced again with the state.

@tkrugg
Copy link
Contributor Author

tkrugg commented Nov 26, 2019

I ran the current PR on vue-instantsearch@develop, react-instantsearch@master and instantsearch.js@develop and it's working!

@tkrugg tkrugg merged commit b52ea34 into master Nov 26, 2019
@tkrugg tkrugg deleted the reset-searchbox-before-setting-value branch November 26, 2019 11:27
Haroenv pushed a commit to algolia/instantsearch 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 to algolia/instantsearch 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 subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants