Skip to content

Commit 78bec93

Browse files
authored
Merge pull request #694 from devtron-labs/fix/shortcut
fix: key missing in case of custom keydown events
2 parents 402c559 + 268b901 commit 78bec93

File tree

4 files changed

+14
-10
lines changed

4 files changed

+14
-10
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@devtron-labs/devtron-fe-common-lib",
3-
"version": "1.10.0-patch-8",
3+
"version": "1.10.0-patch-9",
44
"description": "Supporting common component library",
55
"type": "module",
66
"main": "dist/index.js",

src/Common/Hooks/UseRegisterShortcut/UseRegisterShortcutProvider.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,9 @@ const UseRegisterShortcutProvider = ({
121121
}
122122

123123
if (
124-
ignoredTags.map((tag) => tag.toUpperCase()).indexOf((event.target as HTMLElement).tagName.toUpperCase()) >
124+
// NOTE: in case of custom events generated by password managers autofill, the event.key is not set
125+
!event.key ||
126+
ignoredTags.map((tag) => tag.toUpperCase()).indexOf((event.target as HTMLElement).tagName?.toUpperCase()) >
125127
-1 ||
126128
(event.target as HTMLElement)?.role === 'textbox' ||
127129
disableShortcutsRef.current

src/Shared/Components/FileUpload/FileUpload.tsx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@
1414
* limitations under the License.
1515
*/
1616

17-
import { ChangeEvent } from 'react'
17+
import { ChangeEvent, useMemo } from 'react'
1818

19-
import { ReactComponent as ICUploadArrowAnimated } from '@Icons/ic-upload-arrow-animated.svg'
20-
import { ReactComponent as ICFileText } from '@Icons/ic-file-text.svg'
2119
import { ReactComponent as ICCross } from '@Icons/ic-cross.svg'
20+
import { ReactComponent as ICFileText } from '@Icons/ic-file-text.svg'
21+
import { ReactComponent as ICUploadArrowAnimated } from '@Icons/ic-upload-arrow-animated.svg'
2222
import { Tooltip } from '@Common/Tooltip'
23-
2423
import { ComponentSizeType } from '@Shared/constants'
24+
import { getUniqueId } from '@Shared/Helpers'
2525

2626
import { Button, ButtonStyleType, ButtonVariantType } from '../Button'
2727
import { FileUploadProps } from './types'
@@ -36,6 +36,8 @@ export const FileUpload = ({
3636
fileTypes = [],
3737
onUpload,
3838
}: FileUploadProps) => {
39+
const id = useMemo(() => `fileInput-${getUniqueId()}`, [])
40+
3941
// METHODS
4042
const handleFileChange = (event: ChangeEvent<HTMLInputElement>) => {
4143
if (event.target.files) {
@@ -88,11 +90,11 @@ export const FileUpload = ({
8890
) : (
8991
<div className="dc__position-rel flex">
9092
{/* eslint-disable-next-line jsx-a11y/label-has-associated-control */}
91-
<label htmlFor="fileInput" className="m-0 fw-4 cb-5 fs-13 lh-20 flex-grow-1 cursor">
93+
<label htmlFor={id} className="m-0 fw-4 cb-5 fs-13 lh-20 flex-grow-1 cursor">
9294
{label || 'Upload file…'}
9395
</label>
9496
<input
95-
id="fileInput"
97+
id={id}
9698
type="file"
9799
className="dc__visibility-hidden dc__position-abs dc__top-0 dc__right-0 dc__bottom-0 dc__left-0"
98100
onChange={handleFileChange}

0 commit comments

Comments
 (0)