Skip to content

Commit

Permalink
Read-only is not working in file-attachment
Browse files Browse the repository at this point in the history
  • Loading branch information
Pavitra Khatri committed Apr 23, 2024
1 parent 7851278 commit ded2602
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 6 deletions.
Expand Up @@ -156,7 +156,6 @@
}

updateEnabled(enabled, state) {
this.toggle(enabled, FormView.Constants.ARIA_DISABLED, true);
this.element.setAttribute(FormView.Constants.DATA_ATTRIBUTE_ENABLED, enabled);
let widgets = this.widget;
widgets.forEach(widget => {
Expand Down
Expand Up @@ -84,7 +84,6 @@
}

updateEnabled(enabled, state) {
this.toggle(enabled, FormView.Constants.ARIA_DISABLED, true);
this.element.setAttribute(FormView.Constants.DATA_ATTRIBUTE_ENABLED, enabled);
let widget = this.widget;
if (enabled === false) {
Expand Down
Expand Up @@ -86,6 +86,19 @@
return this.element.querySelector(FileInputV2.selectors.attachButtonLabel);
}

updateEnabled(enabled, state) {
if (this.widget) {
this.element.setAttribute(FormView.Constants.DATA_ATTRIBUTE_ENABLED, enabled);
if (enabled === false || state.readOnly === true) {
this.widget.setAttribute("disabled", "disabled");
this.widget.setAttribute(FormView.Constants.ARIA_DISABLED, true);
} else {
this.widget.removeAttribute("disabled");
this.widget.removeAttribute(FormView.Constants.ARIA_DISABLED);
}
}
}

updateValue(value) {
if (this.widgetObject == null) {
this.widgetObject = new FileInputWidget(this.widgetFields);
Expand Down
Expand Up @@ -94,7 +94,6 @@
}

updateEnabled(enabled, state) {
this.toggle(enabled, FormView.Constants.ARIA_DISABLED, true);
this.element.setAttribute(FormView.Constants.DATA_ATTRIBUTE_ENABLED, enabled);
let widgets = this.widget;
widgets.forEach(widget => {
Expand All @@ -110,7 +109,7 @@
});
}

updateReadOnly(readonly, state) {
updateReadOnly(readonly) {
let widgets = this.widget;
this.element.setAttribute(FormView.Constants.DATA_ATTRIBUTE_READONLY, readonly);
widgets.forEach(widget => {
Expand Down
3 changes: 1 addition & 2 deletions ui.frontend/src/view/FormFieldBase.js
Expand Up @@ -415,7 +415,6 @@ class FormFieldBase extends FormField {
*/
updateEnabled(enabled, state) {
if (this.widget) {
this.toggle(enabled, Constants.ARIA_DISABLED, true);
this.element.setAttribute(Constants.DATA_ATTRIBUTE_ENABLED, enabled);
if (enabled === false) {
this.widget.setAttribute("disabled", "disabled");
Expand All @@ -432,7 +431,7 @@ class FormFieldBase extends FormField {
* @param {boolean} readOnly - The read-only state.
* @param {Object} state - The state object.
*/
updateReadOnly(readOnly, state) {
updateReadOnly(readOnly) {
if (this.widget) {
this.element.setAttribute(Constants.DATA_ATTRIBUTE_READONLY, readOnly);
if (readOnly === true) {
Expand Down

0 comments on commit ded2602

Please sign in to comment.