Skip to content

Commit

Permalink
Fixed #7927 - File Upload - The upload file button remains highlighte…
Browse files Browse the repository at this point in the history
…d and clickble in read-only mode
  • Loading branch information
tsv2013 committed Mar 11, 2024
1 parent 4dae403 commit f19453a
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/defaultCss/defaultV2Css.ts
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
@@ -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
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
16 changes: 16 additions & 0 deletions tests/questionFileTests.ts
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");
});

0 comments on commit f19453a

Please sign in to comment.