@@ -29,6 +29,7 @@ class SLDSLookup extends React.Component {
2929 this . state = {
3030 searchTerm : '' ,
3131 isOpen :false ,
32+ activeItem :null ,
3233 selectedIndex : null ,
3334 activeIndex :null ,
3435 } ;
@@ -48,8 +49,8 @@ class SLDSLookup extends React.Component {
4849 } )
4950 }
5051
51- getActiveDescendant ( ) {
52- return this . state . activeIndex !== null ? 'item-' + this . state . activeIndex : "" ;
52+ setActiveDescendant ( id ) {
53+ this . setState ( { activeItem : id } ) ;
5354 }
5455
5556 //=================================================
@@ -120,7 +121,7 @@ class SLDSLookup extends React.Component {
120121 //If user hits enter/space key, select current activedescendant item
121122 else if ( ( event . keyCode === KEYS . ENTER || event . keyCode === KEYS . SPACE ) && this . state . activeIndex !== null ) {
122123 EventUtil . trapImmediate ( event ) ;
123- this . selectItem ( this . state . activeIndex ) ;
124+ this . selectItem ( this . state . activeItem ) ;
124125 }
125126 }
126127 }
@@ -135,6 +136,7 @@ class SLDSLookup extends React.Component {
135136 onSelect = { this . selectItem . bind ( this ) }
136137 label = { this . props . label }
137138 items = { this . props . items }
139+ setActiveDescendant = { this . setActiveDescendant . bind ( this ) }
138140 activeIndex = { this . state . activeIndex } /> ;
139141 } else {
140142 return null ;
@@ -177,12 +179,12 @@ class SLDSLookup extends React.Component {
177179 aria-label = "lookup"
178180 aria-haspopup = "true"
179181 aria-autocomplete = "list"
180- aria-activedescendant = { this . getActiveDescendant ( ) }
182+ aria-activedescendant = { this . state . activeItem ? this . state . activeItem : "" }
181183 aria-expanded = { this . state . isOpen }
182184 role = "combobox"
183185 onChange = { this . handleChange . bind ( this ) }
184186 onFocus = { this . handleFocus . bind ( this ) }
185- // onBlur={this.handleBlur.bind(this)}
187+ onBlur = { this . handleBlur . bind ( this ) }
186188 onClick = { this . handleClick . bind ( this ) }
187189 onKeyDown = { this . handleKeyDown . bind ( this ) }
188190 value = { this . state . searchTerm } />
0 commit comments