reactivesearch icon indicating copy to clipboard operation
reactivesearch copied to clipboard

DataSearch input field custom attributes

Open joergac opened this issue 6 years ago • 2 comments

Issue Type: enhancement

Platform: Web

Description: I am looking for a way to add custom attributes to the input field of my DataSearch component.

My use case is that I'd like to add aria-labels to my input for seo related issues. Chrome lighthouse complains about this.

image

Reactivesearch version: 3.0.0

Browser: all

joergac avatar May 24 '19 05:05 joergac

We can have a new prop in search components to define the props applied to input element.

Meanwhile, you can use ref to set the attributes.

for example:

  1. Access the input ref
<DataSearch
  ref={ c => this.inputRef = c._inputRef; }
/>

  1. Use it to set attributes
React.findDOMNode(this.inputRef).setAttribute('aria-label', 'xyz');

bietkul avatar Jun 03 '19 11:06 bietkul

Similarly, adding type="search" to the DataSearch component's input would improve accessibility for mobile devices and screen readers.

gauthierm avatar Feb 21 '20 18:02 gauthierm