fix(web): associate app deletion confirmation label (#40375)

This commit is contained in:
yyh 2026-08-10 09:52:09 +08:00 committed by GitHub
parent e06f0ee315
commit dee9d27af8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 16 additions and 4 deletions

View File

@ -190,9 +190,6 @@
}
},
"web/app/components/app-sidebar/app-info/app-info-modals.tsx": {
"jsx_a11y/label-has-associated-control": {
"count": 1
},
"no-restricted-imports": {
"count": 1
}

View File

@ -190,6 +190,16 @@ describe('AppInfoModals', () => {
})
})
it('should name the delete confirmation input with its visible label', async () => {
await act(async () => {
render(<AppInfoModals {...defaultProps} activeModal="delete" />)
})
expect(
await screen.findByRole('textbox', { name: /app\.deleteAppConfirmInputLabel/ }),
).toBeInTheDocument()
})
it('should render UpdateDSLModal when activeModal is importDSL', async () => {
await act(async () => {
render(<AppInfoModals {...defaultProps} activeModal="importDSL" />)

View File

@ -64,6 +64,7 @@ const AppInfoModals = ({
const { t } = useTranslation()
const [confirmDeleteInput, setConfirmDeleteInput] = useState('')
const [isSecretExporting, setIsSecretExporting] = useState(false)
const confirmDeleteInputId = React.useId()
const isDeleteConfirmDisabled = confirmDeleteInput !== appDetail.name
const exportDialogMode =
secretEnvList.length > 0 ? 'secret' : activeModal === 'exportWarning' ? 'warning' : null
@ -147,7 +148,10 @@ const AppInfoModals = ({
{t(($) => $.deleteAppConfirmContent, { ns: 'app' })}
</AlertDialogDescription>
<div className="mt-2">
<label className="mb-1 block system-sm-regular text-text-secondary">
<label
htmlFor={confirmDeleteInputId}
className="mb-1 block system-sm-regular text-text-secondary"
>
<Trans
i18nKey={($) => $.deleteAppConfirmInputLabel}
ns="app"
@ -161,6 +165,7 @@ const AppInfoModals = ({
</label>
<div className="relative">
<Input
id={confirmDeleteInputId}
type="text"
autoComplete="off"
spellCheck={false}