Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed #7927 - File Upload - The upload file button remains highlighted and clickble in read-only mode #7942

Merged
merged 2 commits into from
Mar 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/defaultCss/defaultV2Css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -608,6 +608,7 @@ export var defaultV2Css = {
chooseFileAsIcon: "sd-file__choose-btn--icon",
chooseFileIconId: "icon-choosefile",
disabled: "sd-file__choose-btn--disabled",
controlDisabled: "sd-file__choose-file-btn--disabled",
//todo: remove it in v2
removeButton: "sd-context-btn--negative",
removeButtonBottom: "",
Expand Down
10 changes: 9 additions & 1 deletion src/defaultV2-theme/blocks/sd-file.scss
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
@import "../variables.scss";

.sd-file {
position: relative;
font-size: calcFontSize(1);
line-height: calcLineHeight(1.5);
min-height: calcSize(36);
box-sizing: border-box;
padding: 0 calcSize(6);

.sv-action-bar {
padding: calcSize(1) 0;
justify-content: center;
Expand Down Expand Up @@ -58,6 +59,7 @@
container-type: unset;
}
}

.sd-file__decorator--drag {
z-index: 1;
border: 1px solid $primary;
Expand Down Expand Up @@ -89,6 +91,7 @@
.sd-file__drag-area-placeholder {
display: none;
}

.sd-file__decorator .sd-action {
padding: calcSize(1);

Expand Down Expand Up @@ -404,4 +407,9 @@
top: 50%;
transform: translate(-50%, -50%);
}
}

.sd-file__choose-file-btn--disabled {
opacity: 0.25;
cursor: default;
}
1 change: 1 addition & 0 deletions src/question_file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ export class QuestionFileModel extends QuestionFileModelBase {
id: "sv-file-choose-file",
iconSize: "auto",
data: { question: this },
enabledIf: () => !this.isInputReadOnly,
component: "sv-file-choose-btn"
});
this.startCameraAction = new Action({
Expand Down
2 changes: 1 addition & 1 deletion tests/markup/snapshots/file-2-zip-png-ro.snap.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<div class="sd-action-bar sd-file__actions-container">
<div class="sv-action" id="sv-file-choose-file">
<div class="sv-action__content">
<label aria-label="Select File" class="sd-context-btn sd-file__choose-btn sd-file__choose-btn--icon" for="testid0i" tabindex="0">
<label aria-label="Select File" class="sd-context-btn sd-file__choose-btn sd-file__choose-btn--icon sd-file__choose-file-btn--disabled" for="testid0i" tabindex="0">
<svg class="sv-svg-icon" role="img">
<use xlink:href="#icon-choosefile" class="">
</use>
Expand Down
2 changes: 1 addition & 1 deletion tests/markup/snapshots/file-mob2-zip-png-ro.snap.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<div class="sd-action-bar sd-file__actions-container">
<div class="sv-action" id="sv-file-choose-file">
<div class="sv-action__content">
<label aria-label="Select File" class="sd-context-btn sd-file__choose-btn sd-file__choose-btn--icon" for="testid0i" tabindex="0">
<label aria-label="Select File" class="sd-context-btn sd-file__choose-btn sd-file__choose-btn--icon sd-file__choose-file-btn--disabled" for="testid0i" tabindex="0">
<svg class="sv-svg-icon" role="img">
<use xlink:href="#icon-choosefile" class="">
</use>
Expand Down
16 changes: 16 additions & 0 deletions tests/questionFileTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1901,3 +1901,19 @@ QUnit.test("Acton takePhoto should be serialiazed", function (assert) {
assert.equal(action.title, "Foto machen", "de");
});

QUnit.test("Choose file action should have disabled class", function (assert) {
const survey = new SurveyModel({
mode: "display",
elements: [
{ type: "file", name: "q1", maxSize: 3 },
]
});
survey.css = defaultV2Css;
const question = <QuestionFileModel>survey.getAllQuestions()[0];
assert.equal(question.getChooseFileCss(), "sd-file__choose-btn sd-file__choose-file-btn--disabled sd-action sd-file__choose-btn--text sd-action--disabled", "Disabled");
survey.mode = "edit";
assert.equal(question.getChooseFileCss(), "sd-file__choose-btn sd-action sd-file__choose-btn--text", "Enabled");
survey.mode = "display";
assert.equal(question.getChooseFileCss(), "sd-file__choose-btn sd-file__choose-file-btn--disabled sd-action sd-file__choose-btn--text sd-action--disabled", "Disabled");
});

Loading