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(enterKeyHint): use a fixed enterKeyHint value on Samsung devices #916

Merged
merged 10 commits into from
Mar 30, 2022

Conversation

FabienMotte
Copy link
Contributor

This PR tries to fix #651.

Issue summary

On a Samsung device using Chrome Android with the Predictive Search feature enabled, the input value is reset when enterKeyHint property is updated (between "search" and "go").

Result

Based on the current user agent, we detect the device vendor (Samsung), type (mobile or tablet), OS (Android) and browser (Chrome). If all these conditions are matching (samsung && (mobile || tablet) && android && chrome), we use a fixed "enter" value for enterKeyHint property.

@FabienMotte FabienMotte requested review from dhayab and sarahdayan March 8, 2022 10:32
@codesandbox-ci
Copy link

codesandbox-ci bot commented Mar 8, 2022

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit ec86a12:

Sandbox Source
@algolia/autocomplete-example-github-repositories-custom-plugin Configuration
@algolia/autocomplete-example-instantsearch Configuration
algolia/autocomplete Configuration
algolia/autocomplete Configuration
@algolia/autocomplete-example-react-renderer Configuration
algolia/autocomplete Configuration
algolia/autocomplete Configuration
@algolia/autocomplete-example-reshape Configuration
@algolia/autocomplete-example-vue Configuration

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.

Great find—well done!

packages/autocomplete-core/src/utils/isAndroid.ts Outdated Show resolved Hide resolved
packages/autocomplete-core/src/getPropGetters.ts Outdated Show resolved Hide resolved
@FabienMotte FabienMotte requested a review from sarahdayan March 9, 2022 14:35
Copy link
Member

@dhayab dhayab left a comment

Choose a reason for hiding this comment

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

👏

packages/autocomplete-core/src/utils/isChrome.ts Outdated Show resolved Hide resolved
packages/autocomplete-core/src/utils/isAndroid.ts Outdated Show resolved Hide resolved
packages/autocomplete-core/src/utils/isChrome.ts Outdated Show resolved Hide resolved
packages/autocomplete-core/src/utils/isAndroid.ts Outdated Show resolved Hide resolved
packages/autocomplete-core/src/utils/isSamsung.ts Outdated Show resolved Hide resolved
packages/autocomplete-core/src/utils/isSamsung.ts Outdated Show resolved Hide resolved
packages/autocomplete-core/src/utils/isSamsung.ts Outdated Show resolved Hide resolved
@nitech
Copy link

nitech commented Mar 16, 2022

@francoischalifour when can I expect this to be merged?

@sarahdayan
Copy link
Member

sarahdayan commented Mar 16, 2022

Hey @nitech, could you try this version on your app and tell us if this effectively fixes the issue for you?

You can replace your Autocomplete dependencies with these versions in your package.json:

  • https://pkg.csb.dev/algolia/autocomplete/commit/e772e3af/@algolia/autocomplete-core
  • https://pkg.csb.dev/algolia/autocomplete/commit/e772e3af/@algolia/autocomplete-js
  • https://pkg.csb.dev/algolia/autocomplete/commit/e772e3af/@algolia/autocomplete-plugin-algolia-insights
  • https://pkg.csb.dev/algolia/autocomplete/commit/e772e3af/@algolia/autocomplete-plugin-query-suggestions
  • https://pkg.csb.dev/algolia/autocomplete/commit/e772e3af/@algolia/autocomplete-plugin-recent-searches
  • https://pkg.csb.dev/algolia/autocomplete/commit/e772e3af/@algolia/autocomplete-plugin-tags
  • https://pkg.csb.dev/algolia/autocomplete/commit/e772e3af/@algolia/autocomplete-preset-algolia
  • https://pkg.csb.dev/algolia/autocomplete/commit/e772e3af/@algolia/autocomplete-shared
  • https://pkg.csb.dev/algolia/autocomplete/commit/e772e3af/@algolia/autocomplete-theme-classic

Example:

{
  // ...
  "dependencies": {
    "@algolia/autocomplete-js": "https://pkg.csb.dev/algolia/autocomplete/commit/e772e3af/@algolia/autocomplete-js",
    "@algolia/autocomplete-theme-classic": "https://pkg.csb.dev/algolia/autocomplete/commit/e772e3af/@algolia/autocomplete-theme-classic"
  }
}

@FabienMotte FabienMotte requested a review from sarahdayan March 23, 2022 15:40
@FabienMotte FabienMotte requested a review from sarahdayan March 29, 2022 16:33
Copy link
Member

@sarahdayan sarahdayan left a comment

Choose a reason for hiding this comment

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

Final optimization, and then we'll be good to go!

packages/autocomplete-core/src/utils/isSamsung.ts Outdated Show resolved Hide resolved
packages/autocomplete-core/src/utils/isChrome.ts Outdated Show resolved Hide resolved
@FabienMotte FabienMotte enabled auto-merge (squash) March 30, 2022 12:37
@FabienMotte FabienMotte merged commit b4aa087 into next Mar 30, 2022
@FabienMotte FabienMotte deleted the fix/enterKeyHint-samsung branch March 30, 2022 12:40
@nitech
Copy link

nitech commented Apr 5, 2022

@sarahdayan bug still present on user agent:
Mozilla/5.0 (Linux; Android 8.0.0; SAMSUNG SM-G930F) AppleWebKit/537.36 (KHTML, like Gecko) SamsungBrowser/16.2 Chrome/92.0.4515.166 Mobile Safari/537.36

Does Algolia Autocomplete allow me to turn off modifying enterKeyHint?

See my comment on original issue

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.

Random erasing of search query on Chrome 92 Android
6 participants