Skip to content

Commit 24d0d0e

Browse files
[aria-label-prop] change aria-label to aria-labelledby to eliminate redundancy and make it configurable (#1359)
1 parent e7de262 commit 24d0d0e

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

packages/react-bootstrap-table2-toolkit/README.md

+3
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@ Custom the style on input element.
8080
#### delay = [number]
8181
milionsecond for debounce user input.
8282

83+
#### srText = [string]
84+
Customize the screen reader text for the search input. (Default: "Search this table")
85+
8386
### Search Options
8487

8588
#### defaultSearch - [string]

packages/react-bootstrap-table2-toolkit/src/search/SearchBar.js

+10-5
Original file line numberDiff line numberDiff line change
@@ -56,21 +56,24 @@ class SearchBar extends React.Component {
5656
className,
5757
style,
5858
placeholder,
59-
tableId
59+
tableId,
60+
srText
6061
} = this.props;
6162

6263
return (
6364
<label
6465
htmlFor={ `search-bar-${tableId}` }
6566
className="search-label"
6667
>
67-
<span className="sr-only">Search this table</span>
68+
<span id={ `search-bar-${tableId}-label` } className="sr-only">
69+
{ srText }
70+
</span>
6871
<input
6972
ref={ n => this.input = n }
7073
id={ `search-bar-${tableId}` }
7174
type="text"
7275
style={ style }
73-
aria-label="enter text you want to search"
76+
aria-labelledby={ `search-bar-${tableId}-label` }
7477
onKeyUp={ () => this.onKeyup() }
7578
onChange={ this.onChangeValue }
7679
className={ `form-control ${className}` }
@@ -89,7 +92,8 @@ SearchBar.propTypes = {
8992
style: PropTypes.object,
9093
delay: PropTypes.number,
9194
searchText: PropTypes.string,
92-
tableId: PropTypes.string
95+
tableId: PropTypes.string,
96+
srText: PropTypes.string
9397
};
9498

9599
SearchBar.defaultProps = {
@@ -98,7 +102,8 @@ SearchBar.defaultProps = {
98102
placeholder: 'Search',
99103
delay: 250,
100104
searchText: '',
101-
tableId: '0'
105+
tableId: '0',
106+
srText: 'Search this table'
102107
};
103108

104109
export default SearchBar;

0 commit comments

Comments
 (0)