@@ -8,6 +8,7 @@ import ListItem from "@ui5/webcomponents/dist/ListItem.js";
8
8
import Integer from "@ui5/webcomponents-base/dist/types/Integer.js" ;
9
9
import getFileExtension from "@ui5/webcomponents-base/dist/util/getFileExtension.js" ;
10
10
import RenderScheduler from "@ui5/webcomponents-base/dist/RenderScheduler.js" ;
11
+ import { isEnter , isEscape } from "@ui5/webcomponents-base/dist/Keys.js" ;
11
12
import UploadState from "./types/UploadState.js" ;
12
13
import "@ui5/webcomponents-icons/dist/icons/refresh.js" ;
13
14
import "@ui5/webcomponents-icons/dist/icons/stop.js" ;
@@ -206,6 +207,13 @@ const metadata = {
206
207
* @public
207
208
*/
208
209
retry : { } ,
210
+
211
+ /**
212
+ * @since 1.0.0-rc.8
213
+ * @event
214
+ * @private
215
+ */
216
+ "_focus-requested" : { } ,
209
217
} ,
210
218
} ;
211
219
@@ -255,9 +263,10 @@ class UploadCollectionItem extends ListItem {
255
263
this . i18nBundle = getI18nBundle ( "@ui5/webcomponents-fiori" ) ;
256
264
257
265
this . _editPressed = false ; // indicates if the edit btn has been pressed
266
+ this . doNotCloseInput = false ; // Indicates whether the input should be closed when using keybord for navigation
267
+ this . isEnter = false ;
258
268
}
259
269
260
-
261
270
onAfterRendering ( ) {
262
271
if ( this . _editPressed ) {
263
272
this . _editing = true ;
@@ -300,6 +309,21 @@ class UploadCollectionItem extends ListItem {
300
309
}
301
310
}
302
311
312
+ _onInputKeydown ( event ) {
313
+ this . isEnter = isEnter ( event ) ;
314
+ this . isEscape = isEscape ( event ) ;
315
+ }
316
+
317
+ _onInputKeyUp ( event ) {
318
+ this . doNotCloseInput = true ;
319
+ this . tempValue = event . target . value + this . _fileExtension ;
320
+
321
+ if ( this . isEscape ) {
322
+ [ this . fileName , this . tempValue ] = [ this . tempValue , this . fileName ] ;
323
+ return this . _onRenameCancel ( ) ;
324
+ }
325
+ }
326
+
303
327
isDetailPressed ( event ) {
304
328
const path = event . path || ( event . composedPath && event . composedPath ( ) ) ;
305
329
@@ -313,13 +337,40 @@ class UploadCollectionItem extends ListItem {
313
337
return ;
314
338
}
315
339
340
+ if ( ( ! this . isEnter && this . doNotCloseInput ) || this . isEscape ) {
341
+ [ this . fileName , this . tempValue ] = [ this . tempValue , this . fileName ] ;
342
+ this . isEscape = false ;
343
+ return ;
344
+ }
345
+
316
346
this . _editing = false ;
317
347
this . fileName = event . target . value + this . _fileExtension ;
318
348
this . fireEvent ( "rename" ) ;
349
+
350
+ if ( this . isEnter ) {
351
+ this . _focus ( ) ;
352
+ }
353
+ }
354
+
355
+ _onRename ( event ) {
356
+ this . doNotCloseInput = false ;
357
+ this . _editing = false ;
358
+ this . _focus ( ) ;
319
359
}
320
360
321
361
_onRenameCancel ( event ) {
362
+ if ( ! this . isEscape ) {
363
+ [ this . fileName , this . tempValue ] = [ this . tempValue , this . fileName ] ;
364
+ }
365
+
322
366
this . _editing = false ;
367
+ this . doNotCloseInput = false ;
368
+
369
+ this . _focus ( ) ;
370
+ }
371
+
372
+ _focus ( ) {
373
+ this . fireEvent ( "_focus-requested" ) ;
323
374
}
324
375
325
376
_onFileNameClick ( event ) {
@@ -334,6 +385,10 @@ class UploadCollectionItem extends ListItem {
334
385
this . fireEvent ( "terminate" ) ;
335
386
}
336
387
388
+ get list ( ) {
389
+ return this . assignedSlot . parentElement ;
390
+ }
391
+
337
392
/**
338
393
* @override
339
394
*/
0 commit comments