Skip to content

Commit 26dcd13

Browse files
frontend: DropZoneBox: Remove role=button from label element
1 parent d7d68c3 commit 26dcd13

File tree

3 files changed

+13
-12
lines changed

3 files changed

+13
-12
lines changed

frontend/src/components/common/DropZoneBox.stories.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ UploadFiles.args = {
3434
<Typography sx={{ m: 2 }}>{'Select a file or drag and drop here'}</Typography>
3535
<Button
3636
variant="contained"
37-
component="label"
3837
startIcon={<InlineIcon icon="mdi:upload" width={32} />}
3938
sx={{ fontWeight: 500 }}
4039
>

frontend/src/components/common/Resource/UploadDialog.tsx

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ const UploadFromFilesystem = ({
7070
const [files, setFiles] = React.useState<File[]>([]);
7171
const [dragOver, setDragOver] = React.useState(false);
7272
const [error, setError] = React.useState('');
73+
const fileInputRef = React.useRef<HTMLInputElement>(null);
7374

7475
const onFilesPicked = (picked: FileList | null) => {
7576
setError('');
@@ -123,19 +124,20 @@ const UploadFromFilesystem = ({
123124
</Typography>
124125
<Button
125126
variant="contained"
126-
component="label"
127127
startIcon={<InlineIcon icon="mdi:upload" width={32} />}
128128
sx={{ fontWeight: 500 }}
129+
onClick={() => fileInputRef.current?.click()}
129130
>
130131
{t('translation|Select File')}
131-
<input
132-
type="file"
133-
accept=".yaml,.yml,application/yaml"
134-
multiple
135-
hidden
136-
onChange={e => onFilesPicked(e.target.files)}
137-
/>
138132
</Button>
133+
<input
134+
type="file"
135+
accept=".yaml,.yml,application/yaml"
136+
multiple
137+
hidden
138+
ref={fileInputRef}
139+
onChange={e => onFilesPicked(e.target.files)}
140+
/>
139141
</DropZoneBox>
140142
{!!files.length && (
141143
<Box

frontend/src/components/common/__snapshots__/DropZoneBox.UploadFiles.stories.storyshot

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
>
99
Select a file or drag and drop here
1010
</p>
11-
<label
11+
<button
1212
class="MuiButtonBase-root MuiButton-root MuiButton-contained MuiButton-containedPrimary MuiButton-sizeMedium MuiButton-containedSizeMedium MuiButton-colorPrimary MuiButton-disableElevation MuiButton-root MuiButton-contained MuiButton-containedPrimary MuiButton-sizeMedium MuiButton-containedSizeMedium MuiButton-colorPrimary MuiButton-disableElevation css-17g4n8r-MuiButtonBase-root-MuiButton-root"
13-
role="button"
1413
tabindex="0"
14+
type="button"
1515
>
1616
<span
1717
class="MuiButton-icon MuiButton-startIcon MuiButton-iconSizeMedium css-1d6wzja-MuiButton-startIcon"
@@ -20,7 +20,7 @@
2020
<span
2121
class="MuiTouchRipple-root css-8je8zh-MuiTouchRipple-root"
2222
/>
23-
</label>
23+
</button>
2424
</div>
2525
</div>
2626
</body>

0 commit comments

Comments
 (0)