Skip to content
Prev Previous commit
Next Next commit
[aria-label-prop] change aria-label to aria-labelledby to eliminate r…
…edundancy and make it configurable (#1359)
  • Loading branch information
chimericdream authored May 17, 2020
commit 24d0d0e7c739ffc82ddc1d9169187ce4e24ef5ac
3 changes: 3 additions & 0 deletions packages/react-bootstrap-table2-toolkit/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ Custom the style on input element.
#### delay = [number]
milionsecond for debounce user input.

#### srText = [string]
Customize the screen reader text for the search input. (Default: "Search this table")

### Search Options

#### defaultSearch - [string]
Expand Down
15 changes: 10 additions & 5 deletions packages/react-bootstrap-table2-toolkit/src/search/SearchBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,21 +56,24 @@ class SearchBar extends React.Component {
className,
style,
placeholder,
tableId
tableId,
srText
} = this.props;

return (
<label
htmlFor={ `search-bar-${tableId}` }
className="search-label"
>
<span className="sr-only">Search this table</span>
<span id={ `search-bar-${tableId}-label` } className="sr-only">
{ srText }
</span>
<input
ref={ n => this.input = n }
id={ `search-bar-${tableId}` }
type="text"
style={ style }
aria-label="enter text you want to search"
aria-labelledby={ `search-bar-${tableId}-label` }
onKeyUp={ () => this.onKeyup() }
onChange={ this.onChangeValue }
className={ `form-control ${className}` }
Expand All @@ -89,7 +92,8 @@ SearchBar.propTypes = {
style: PropTypes.object,
delay: PropTypes.number,
searchText: PropTypes.string,
tableId: PropTypes.string
tableId: PropTypes.string,
srText: PropTypes.string
};

SearchBar.defaultProps = {
Expand All @@ -98,7 +102,8 @@ SearchBar.defaultProps = {
placeholder: 'Search',
delay: 250,
searchText: '',
tableId: '0'
tableId: '0',
srText: 'Search this table'
};

export default SearchBar;