@@ -188,61 +188,6 @@ governing permissions and limitations under the License.
188
188
} ) ;
189
189
} ) ( ) ;
190
190
191
- // Inputgroup
192
- ( function ( ) {
193
- function setFocus ( inputgroup , focused , event ) {
194
- var textfields = inputgroup . querySelectorAll ( ".spectrum-Textfield" ) ;
195
- var inputs = inputgroup . querySelectorAll ( ".spectrum-InputGroup-input" ) ;
196
- var input = inputs [ 0 ] ;
197
- var focusClass = event . target . classList . contains ( "is-keyboardFocused" )
198
- ? "is-keyboardFocused"
199
- : "is-focused" ;
200
- var pickerButton = inputgroup . querySelector ( ".spectrum-PickerButton" ) ;
201
- if ( focused ) {
202
- inputgroup . classList . add ( focusClass ) ;
203
- if ( pickerButton ) pickerButton . classList . add ( focusClass ) ;
204
- if ( event . target . tagName !== "INPUT" ) {
205
- input . focus ( ) ;
206
- }
207
-
208
- Array . prototype . forEach . call ( textfields , ( textfield ) => {
209
- textfield . classList . add ( focusClass ) ;
210
- } ) ;
211
- } else {
212
- if ( pickerButton ) pickerButton . classList . remove ( "is-keyboardFocused" ) ;
213
- if ( pickerButton ) pickerButton . classList . remove ( "is-focused" ) ;
214
- inputgroup . classList . remove ( "is-keyboardFocused" ) ;
215
- inputgroup . classList . remove ( "is-focused" ) ;
216
-
217
- Array . prototype . forEach . call ( textfields , ( textfield ) => {
218
- textfield . classList . remove ( "is-focused" ) ;
219
- textfield . classList . remove ( "is-keyboardFocused" ) ;
220
- } ) ;
221
- }
222
- }
223
-
224
- document . addEventListener ( "focusin" , function ( event ) {
225
- var inputgroup = event . target . closest ( ".spectrum-InputGroup" ) ;
226
-
227
- if ( event . target . closest ( ".spectrum-Menu" ) ) {
228
- // Don't mess with focus on menuitems
229
- return ;
230
- }
231
-
232
- if ( inputgroup ) {
233
- setFocus ( inputgroup , true , event ) ;
234
- }
235
- } ) ;
236
-
237
- document . addEventListener ( "focusout" , function ( event ) {
238
- var inputgroup = event . target . closest ( ".spectrum-InputGroup" ) ;
239
-
240
- if ( inputgroup ) {
241
- setFocus ( inputgroup , false , event ) ;
242
- }
243
- } ) ;
244
- } ) ( ) ;
245
-
246
191
// Stepper
247
192
( function ( ) {
248
193
function setFocus ( stepper , input , focused ) {
@@ -1026,6 +971,22 @@ function onKeydownHandler(event) {
1026
971
}
1027
972
}
1028
973
974
+ function onMousedownHandler ( ) {
975
+ keyboardFocus = false ;
976
+ var elements = document . getElementsByClassName ( 'is-keyboardFocused' ) ;
977
+
978
+ for ( var i = 0 ; i < elements . length ; i ++ ) {
979
+ elements [ i ] . classList . remove ( 'is-keyboardFocused' ) ;
980
+ }
981
+
982
+ if ( document . activeElement &&
983
+ document . activeElement !== document . body ) {
984
+ document . activeElement . classList . add ( 'is-focused' ) ;
985
+ }
986
+
987
+
988
+ }
989
+
1029
990
function onFocusHandler ( event ) {
1030
991
var classList = event . target . classList ;
1031
992
if ( classList && keyboardFocus ) {
@@ -1035,6 +996,7 @@ function onFocusHandler(event) {
1035
996
1036
997
window . addEventListener ( 'keydown' , onKeydownHandler , true ) ;
1037
998
window . addEventListener ( 'focus' , onFocusHandler , true ) ;
999
+ window . addEventListener ( 'mousedown' , onMousedownHandler , true ) ;
1038
1000
1039
1001
animateCircleLoaders ( ) ;
1040
1002
window . addEventListener ( "PageFastLoaded" , enhanceAll ) ;
0 commit comments