diff --git a/components/file-input/src/file-list/file-list-item.js b/components/file-input/src/file-list/file-list-item.js
index eae111a07d..71eaa160a4 100644
--- a/components/file-input/src/file-list/file-list-item.js
+++ b/components/file-input/src/file-list/file-list-item.js
@@ -14,91 +14,108 @@ const FileListItem = ({
onCancel,
cancelText,
dataTest,
-}) => (
-
-
- {loading ? (
-
- ) : (
-
- )}
-
+}) => {
+ const handleKeyDown = (event) => {
+ if (!onRemove) {
+ return
+ }
+ if (
+ event.key === 'Enter' ||
+ event.key === 'Backspace' ||
+ event.key === 'Delete'
+ ) {
+ onRemove({}, event)
+ }
+ }
-
- {label}
+ return (
+
+
+ {loading ? (
+
+ ) : (
+
+ )}
+
- {loading && onCancel && cancelText && (
- onCancel({}, event)}
- data-test={`${dataTest}-cancel`}
- >
- {cancelText}
-
- )}
+
+ {label}
- {!loading && (
- onRemove({}, event)}
- data-test={`${dataTest}-remove`}
- >
- {removeText}
-
- )}
-
+ {loading && onCancel && cancelText && (
+ onCancel({}, event)}
+ data-test={`${dataTest}-cancel`}
+ >
+ {cancelText}
+
+ )}
-
-
-)
+ {!loading && (
+ onRemove({}, event)}
+ data-test={`${dataTest}-remove`}
+ tabIndex={0}
+ onKeyDown={handleKeyDown}
+ >
+ {removeText}
+
+ )}
+
+
+
+
+ )
+}
FileListItem.defaultProps = {
dataTest: 'dhis2-uicore-filelistitem',