Skip to content

Commit d4dc86a

Browse files
committed
Add aria-labelledby to picklist component. Remove it from dropdown. Based on Jesse, Stef advice
1 parent a8e4e80 commit d4dc86a

File tree

4 files changed

+11
-11
lines changed

4 files changed

+11
-11
lines changed

components/SLDSDropdownBase/index.jsx

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ module.exports = React.createClass( {
5555

5656
getInitialState(){
5757
return {
58-
triggerId:null,
5958
isOpen:false,
6059
isFocused:false,
6160
isClosing:false,
@@ -68,8 +67,6 @@ module.exports = React.createClass( {
6867
},
6968

7069
componentDidMount(){
71-
const id = React.findDOMNode(this.refs.button).getAttribute("data-reactid");
72-
this.setState({triggerId:id});
7370
if(this.props.initialFocus){
7471
this.setFocus();
7572
}
@@ -242,7 +239,6 @@ module.exports = React.createClass( {
242239

243240
getPopoverContent(){
244241
return <List
245-
triggerId={this.state.triggerId}
246242
ref='list'
247243
options={this.props.options}
248244
className={this.props.listClassName}
@@ -321,7 +317,6 @@ module.exports = React.createClass( {
321317

322318
return <SLDSButton
323319
ref='button'
324-
id={this.state.triggerId}
325320
aria-haspopup='true'
326321
label={this.props.label}
327322
className={this.props.className}

components/SLDSDropdownBase/list.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ module.exports = React.createClass({
163163
ref="scroll"
164164
className={"slds-dropdown__list slds-theme--"+this.props.theme}
165165
role="menu"
166-
aria-labelledby={this.props.triggerId}>
166+
>
167167
{ this.getItems() }
168168
</ul>
169169
</div>

components/SLDSPicklistBase/index.jsx

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ module.exports = React.createClass( {
4747

4848
getInitialState(){
4949
return {
50+
triggerId:null,
5051
isOpen:false,
5152
isFocused:false,
5253
highlightedIndex:0,
@@ -57,6 +58,9 @@ module.exports = React.createClass( {
5758
},
5859

5960
componentDidMount () {
61+
const id = React.findDOMNode(this.refs.triggerbutton).getAttribute("data-reactid");
62+
this.setState({triggerId:id});
63+
6064
if(this.props.initialFocus){
6165
this.setFocus();
6266
}
@@ -122,7 +126,7 @@ module.exports = React.createClass( {
122126

123127
setFocus () {
124128
if(this.isMounted()){
125-
React.findDOMNode(this.refs.button).focus();
129+
React.findDOMNode(this.refs.triggerbutton).focus();
126130
}
127131
},
128132

@@ -160,6 +164,7 @@ module.exports = React.createClass( {
160164

161165
getPopoverContent() {
162166
return <List
167+
triggerId={this.state.triggerId}
163168
ref='list'
164169
options={this.props.options}
165170
label={this.props.label}
@@ -216,8 +221,8 @@ module.exports = React.createClass( {
216221
<div className={"slds-form-element slds-theme--"+this.props.theme}>
217222
<div className={"slds-picklist slds-theme--"+this.props.theme}>
218223
<button
219-
id={this.props.id}
220-
ref="button"
224+
id={this.state.triggerId}
225+
ref="triggerbutton"
221226
className={'slds-button slds-button--neutral slds-picklist__label '+this.props.className }
222227
aria-haspopup="true"
223228
onBlur={this.handleBlur}
@@ -272,4 +277,4 @@ module.exports = React.createClass( {
272277
});
273278

274279
module.exports.ListItem = ListItem;
275-
module.exports.ListItemLabel = ListItemLabel;
280+
module.exports.ListItemLabel = ListItemLabel;

components/SLDSPicklistBase/list.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ module.exports = React.createClass({
166166
ref="scroll"
167167
className={"slds-dropdown__list slds-theme--"+this.props.theme}
168168
role="menu"
169-
aria-labelledby={this.props.label}>
169+
aria-labelledby={this.props.triggerId}>
170170
{ this.getItems() }
171171
</ul>
172172
</div>

0 commit comments

Comments
 (0)