Open
Description
Problem
The current suggestion
prop in the TextField component (documentation) has critical functional and accessibility issues:
- Unexpected Behavior: The inline suggestion does not clear correctly when pressing Backspace, leading to potential data inconsistencies.
- Accessibility Violations:
- The suggestion text is not programmatically linked to the input, making it unclear for screen reader users.
- On blur, the suggestion overrides the input value without explicit user consent, violating WCAG Success Criterion 3.2.2 (Predictable Input).
- Usability Concerns: The forced suggestion interaction pattern conflicts with standard input expectations, risking user confusion.
How to replicate the problem
- Go to https://polaris.shopify.com/components/selection-and-input/text-field?example=text-field-with-inline-suggestion
- Type "al", Alabama should appear as suggestion.
- Press backspace -> suggestion won't be cleared
- blur the input -> suggestion will still replace old value
Recommended Solution
Deprecate the suggestion
prop and direct users to the Polaris Autocomplete component, which:
- Provides a robust, accessible solution for suggestion-based inputs.
- Handles keyboard navigation, ARIA roles, and screen reader announcements correctly.
- Allows explicit user selection of suggestions without overriding input values unexpectedly.
Deprecation Plan
- Add a deprecation warning when the
suggestion
prop is used, linking to the Autocomplete documentation. - Remove the
suggestion
prop in the next major version of Polaris. - Update all internal Shopify usage of
TextField
with suggestions to migrate to Autocomplete.
Migration Example
Before (TextField with suggestion):
<TextField suggestion="Alabama" />
After (Autocomplete):
<Autocomplete
options={[{value: 'alabama', label: 'Alabama'}]}
onSelect={(value) => {/* Handle selection */}}
/>
Additional Context
- The Autocomplete component adheres to WAI-ARIA design patterns for comboboxes, ensuring accessibility compliance.
- For simple placeholder-like hints without interactivity, recommend using the
placeholder
prop instead.
Metadata
Metadata
Assignees
Labels
No labels