mirror of
https://github.com/jhbruhn/respira.git
synced 2026-01-27 10:23:41 +00:00
fix: Prevent button activation during post-upload state synchronization
Fix the Choose File button remaining clickable during the brief window between upload completion and pattern info retrieval. The issue was that labels don't support the disabled attribute, so when using asChild with a label, the disabled state was ignored. Changes: - Only use asChild when button is enabled (labels can't be disabled) - Keep input and button disabled conditions synchronized - Add uploadProgress check to prevent re-enabling before patternUploaded is true 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
b995eb898e
commit
6e38ba855c
1 changed files with 22 additions and 4 deletions
|
|
@ -256,16 +256,34 @@ export function FileUpload() {
|
||||||
onChange={handleFileChange}
|
onChange={handleFileChange}
|
||||||
id="file-input"
|
id="file-input"
|
||||||
className="hidden"
|
className="hidden"
|
||||||
disabled={isLoading || patternUploaded || isUploading}
|
disabled={
|
||||||
|
isLoading ||
|
||||||
|
patternUploaded ||
|
||||||
|
isUploading ||
|
||||||
|
(uploadProgress > 0 && !patternUploaded)
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
<Button
|
<Button
|
||||||
asChild={!fileService.hasNativeDialogs()}
|
asChild={
|
||||||
|
!fileService.hasNativeDialogs() &&
|
||||||
|
!(
|
||||||
|
isLoading ||
|
||||||
|
patternUploaded ||
|
||||||
|
isUploading ||
|
||||||
|
(uploadProgress > 0 && !patternUploaded)
|
||||||
|
)
|
||||||
|
}
|
||||||
onClick={
|
onClick={
|
||||||
fileService.hasNativeDialogs()
|
fileService.hasNativeDialogs()
|
||||||
? () => handleFileChange()
|
? () => handleFileChange()
|
||||||
: undefined
|
: undefined
|
||||||
}
|
}
|
||||||
disabled={isLoading || patternUploaded || isUploading}
|
disabled={
|
||||||
|
isLoading ||
|
||||||
|
patternUploaded ||
|
||||||
|
isUploading ||
|
||||||
|
(uploadProgress > 0 && !patternUploaded)
|
||||||
|
}
|
||||||
variant="outline"
|
variant="outline"
|
||||||
className="flex-[2]"
|
className="flex-[2]"
|
||||||
>
|
>
|
||||||
|
|
@ -289,7 +307,7 @@ export function FileUpload() {
|
||||||
)}
|
)}
|
||||||
</>
|
</>
|
||||||
) : (
|
) : (
|
||||||
<label htmlFor="file-input" className="flex items-center gap-2">
|
<label htmlFor="file-input" className="flex items-center gap-2 cursor-pointer">
|
||||||
{isLoading ? (
|
{isLoading ? (
|
||||||
<>
|
<>
|
||||||
<Loader2 className="w-3.5 h-3.5 animate-spin" />
|
<Loader2 className="w-3.5 h-3.5 animate-spin" />
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue