@@ -41,7 +41,8 @@ class SLDSLookup extends React.Component {
41
41
if ( this . refs . lookup ) React . findDOMNode ( this . refs . lookup ) . focus ( ) ;
42
42
}
43
43
else if ( ! prevState . selectedIndex && this . state . selectedIndex ) {
44
- if ( this . refs . clearSelectedItemButton ) React . findDOMNode ( this . refs . clearSelectedItemButton ) . focus ( ) ;
44
+ let selectedItem = 'pill-' + this . state . selectedIndex ;
45
+ if ( this . refs [ selectedItem ] ) React . findDOMNode ( this . refs [ selectedItem ] ) . focus ( ) ;
45
46
}
46
47
}
47
48
@@ -141,6 +142,15 @@ class SLDSLookup extends React.Component {
141
142
}
142
143
}
143
144
145
+ handlePillKeyDown ( event ) {
146
+ if ( event . keyCode ) {
147
+ if ( event . keyCode === KEYS . DELETE || event . keyCode === KEYS . BACKSPACE ) {
148
+ EventUtil . trapImmediate ( event ) ;
149
+ this . handleDeleteSelected ( ) ;
150
+ }
151
+ }
152
+ }
153
+
144
154
//=================================================
145
155
// Rendering Things
146
156
renderMenu ( ) {
@@ -164,34 +174,37 @@ class SLDSLookup extends React.Component {
164
174
renderSelectedItem ( ) {
165
175
let selectedItem = this . props . items [ this . state . selectedIndex ] . label ;
166
176
return (
167
- < div className = "slds-pill" >
168
- < a href = "#" className = "slds-pill__label" >
177
+ < a href = "#" className = "slds-pill" ref = { 'pill-' + this . state . selectedIndex } onKeyDown = { this . handlePillKeyDown . bind ( this ) } >
178
+ < span className = "slds-pill__label" >
169
179
< Icon name = { this . props . type } />
170
180
{ selectedItem }
171
- </ a >
181
+ </ span >
172
182
< SLDSButton
173
- label = { 'Remove ' + selectedItem }
183
+ label = 'Press delete to remove'
174
184
variant = 'icon'
175
185
iconName = 'close'
176
186
iconSize = 'medium'
187
+ disabled = { true }
177
188
onClick = { this . handleDeleteSelected . bind ( this ) }
178
189
ref = "clearSelectedItemButton"
179
190
/>
180
- </ div >
191
+ </ a >
181
192
) ;
182
193
}
183
194
184
195
render ( ) {
185
196
let inputClasses = this . state . selectedIndex === null ? 'slds-input' :'slds-input slds-hide' ;
186
197
let componentClasses = this . state . selectedIndex === null ? "slds-lookup ignore-react-onclickoutside" :"slds-lookup ignore-react-onclickoutside slds-has-selection" ;
198
+ let inputContainerClasses = this . state . selectedIndex === null ? '' :' slds-input' ;
199
+ let inputContainerStyle = this . state . selectedIndex === null ? { } : { padding : '5px' } ;
187
200
188
201
return (
189
- < div className = { componentClasses } data-select = "single " data-scope = "single" data-typeahead = "true" >
202
+ < div className = { componentClasses } data-select = "multi " data-scope = "single" data-typeahead = "true" >
190
203
< section className = "slds-form-element" >
191
204
192
205
< label className = "slds-form-element__label" htmlFor = { this . props . type + "Lookup" } > { this . props . label } </ label >
193
206
194
- < div className = "slds-lookup__control slds-input-has-icon slds-input-has-icon--right" >
207
+ < div className = { "slds-lookup__control slds-input-has-icon slds-input-has-icon--right" + inputContainerClasses } style = { inputContainerStyle } >
195
208
{ this . state . selectedIndex !== null ? this . renderSelectedItem ( ) : null }
196
209
< InputIcon name = "search" />
197
210
< input
0 commit comments