Skip to content

Minor changes to aria label and screen reader text #1359

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;