fix(Upload): IsDisabled not work#7556
Conversation
修改上传组件IsDisabled为true时,还能选择文件的问题
|
Thanks for your PR, @Tony-ST0754. Someone from the team will get assigned to your PR shortly and we'll get it reviewed. |
Reviewer's guide (collapsed on small PRs)Reviewer's GuideThis PR fixes the upload component so that when it is disabled (IsDisabled = true), clicking the browse button no longer opens the file selector by adding a guard in the click handler for the browser button in the JavaScript module. Sequence diagram for upload button click handling with disabled checksequenceDiagram
actor User
participant UploadComponent as UploadComponent_el
participant BtnBrowser as Button_btn_browser
participant UploadModule as upload_js_module
participant InputFile as inputFile
User->>BtnBrowser: click
BtnBrowser->>UploadModule: click event
UploadModule->>UploadComponent: querySelector btn-browser
alt Button has class disabled
UploadModule-->>BtnBrowser: return without action
else Button is enabled
UploadModule->>InputFile: click
InputFile-->>User: open file selector
end
File-Level Changes
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- In the click handler, instead of querying
el.querySelector('.btn-browser')each time, cache the button element once duringinitand reuse it for both the disabled check and binding. - Relying solely on the
disabledCSS class to block interaction may be brittle; consider checking the actualdisabledattribute/state on the button or a single source of truth flag onelso the JavaScript behavior cannot drift from the visual state.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In the click handler, instead of querying `el.querySelector('.btn-browser')` each time, cache the button element once during `init` and reuse it for both the disabled check and binding.
- Relying solely on the `disabled` CSS class to block interaction may be brittle; consider checking the actual `disabled` attribute/state on the button or a single source of truth flag on `el` so the JavaScript behavior cannot drift from the visual state.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #7556 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 748 748
Lines 33000 33004 +4
Branches 4588 4589 +1
=========================================
+ Hits 33000 33004 +4
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
UploadBase基类两个已弃用的参数注释中加以说明,以备文档自动化能读取
修改上传组件IsDisabled为true时,还能选择文件的问题
Link issues
fixes #7555
Summary By Copilot
Regression?
Risk
Verification
Packaging changes reviewed?
☑️ Self Check before Merge
Summary by Sourcery
Bug Fixes: