Manage the triggering of touch to search
Touch to Search launched in June of 2015 on Chrome 43 for most Android phones. When the user taps text on any page in Chrome, the word is selected along with relevant surrounding text. The search term appears in a bar at the bottom of the screen, which users can open in an overlay panel to show full search results.
Tap triggering is enabled for any plain text that is selectable and non interactive or not focusable. When the page has a click handler that responds to a tap on text, Touch to Search automatically detects the response and ignores it since we know the developer intended to handle the event. Using a touch-and-hold gesture to manually select text also triggers the Touch to Search bar. Users can enable or disable the feature using a preference under Chrome's Privacy settings.
As the author of a site there are often times when you don't want a tap gesture on certain element to trigger a search. To ensure that Chrome does what you intend, make those elements:
- Focusable: add a
tabindex=-1property on the element.
- Interactive: Use any of several standard ways to indicate that an element is interactive:
- Use accessibility markup to indicate the element has a widget role, or widget attributes. For example, any element with role=button won't trigger. Adding accessibility markup has the added benefit that your page will be more readable by visually impaired users.
preventDefault(), or manipulates the DOM or CSS will not trigger Touch-to-Search.
- Non-selectable: using
-webkit-user-select: none; Non-selectable text will not trigger Touch-to-Search even when using the touch-and-hold gesture.
If Touch to Search does not trigger when or where it should trigger, or triggers intermittently, then elements are probably marked focusable or interactive when they should not be. Use the following procedure to help determine what's preventing Touch to Search from triggering:
- Check if the text is selectable using the touch-and-hold gesture. If the text selects, but the Touch-to-Search bar does not appear, check that the feature has not been disabled on your phone in the Touch to Search setting under Privacy in Chrome. Also note that some low-end devices do not support Touch-to-Search.
- If the triggering never happens, consult the trigger reasons listed above (check if the element is focusable or interactive).
If your page still doesn't behave the way you'd like, file a bug at crbug.com and add the label