Skip to content

Commit

Permalink
♿ [open-formulieren/open-forms#4716] Limiting accessibility changes f…
Browse files Browse the repository at this point in the history
…or most components to only non-multiple instances

#717 (comment)
  • Loading branch information
robinmolen authored and sergei-maertens committed Oct 24, 2024
1 parent 34bdb02 commit c1196ab
Show file tree
Hide file tree
Showing 11 changed files with 55 additions and 12 deletions.
7 changes: 6 additions & 1 deletion src/formio/components/DateField.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,12 @@ class DateField extends DateTimeField {
setErrorClasses(elements, dirty, hasErrors, hasMessages) {
const inputClone = this.element.querySelector('input:not([type="hidden"])');
const targetElements = inputClone ? [inputClone] : [];
setErrorAttributes(targetElements, hasErrors, hasMessages, this.element);

// setErrorAttributes cannot be done for a `multiple` component
// https://github.com/open-formulieren/open-forms-sdk/pull/717#issuecomment-2405060364
if (!this.component.multiple) {
setErrorAttributes(targetElements, hasErrors, hasMessages, this.element);
}
return super.setErrorClasses(targetElements, dirty, hasErrors, hasMessages);
}

Expand Down
10 changes: 8 additions & 2 deletions src/formio/components/DateTimeField.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,14 @@ class DateTimeField extends DateTimeFormio {
}

setErrorClasses(elements, dirty, hasErrors, hasMessages) {
const targetElements = [this.element.querySelector('input:not([type="hidden"])')];
setErrorAttributes(targetElements, hasErrors, hasMessages, this.element);
const inputClone = this.element.querySelector('input:not([type="hidden"])');
const targetElements = inputClone ? [inputClone] : [];

// setErrorAttributes cannot be done for a `multiple` component
// https://github.com/open-formulieren/open-forms-sdk/pull/717#issuecomment-2405060364
if (!this.component.multiple) {
setErrorAttributes(targetElements, hasErrors, hasMessages, this.element);
}
return super.setErrorClasses(targetElements, dirty, hasErrors, hasMessages);
}

Expand Down
6 changes: 5 additions & 1 deletion src/formio/components/Email.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ class Email extends Formio.Components.components.email {
}

setErrorClasses(elements, dirty, hasErrors, hasMessages) {
setErrorAttributes(elements, hasErrors, hasMessages, this.element);
// setErrorAttributes cannot be done for a `multiple` component
// https://github.com/open-formulieren/open-forms-sdk/pull/717#issuecomment-2405060364
if (!this.component.multiple) {
setErrorAttributes(elements, hasErrors, hasMessages, this.element);
}
return super.setErrorClasses(elements, dirty, hasErrors, hasMessages);
}

Expand Down
2 changes: 1 addition & 1 deletion src/formio/components/FileField.js
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ class FileField extends Formio.Components.components.file {
}

setErrorClasses(elements, dirty, hasErrors, hasMessages) {
const input = this.element.querySelector('[ref="fileBrowse"]');
const input = this.refs.fileBrowse;
const targetElements = input ? [input] : [];
setErrorAttributes(targetElements, hasErrors, hasMessages, this.element);
return super.setErrorClasses(targetElements, dirty, hasErrors, hasMessages);
Expand Down
6 changes: 5 additions & 1 deletion src/formio/components/IBANField.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,11 @@ export default class IBANField extends TextField {
}

setErrorClasses(elements, dirty, hasErrors, hasMessages) {
setErrorAttributes(elements, hasErrors, hasMessages, this.element);
// setErrorAttributes cannot be done for a `multiple` component
// https://github.com/open-formulieren/open-forms-sdk/pull/717#issuecomment-2405060364
if (!this.component.multiple) {
setErrorAttributes(elements, hasErrors, hasMessages, this.element);
}
return super.setErrorClasses(elements, dirty, hasErrors, hasMessages);
}
}
6 changes: 5 additions & 1 deletion src/formio/components/Number.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ class Number extends Formio.Components.components.number {
}

setErrorClasses(elements, dirty, hasErrors, hasMessages) {
setErrorAttributes(elements, hasErrors, hasMessages, this.element);
// setErrorAttributes cannot be done for a `multiple` component
// https://github.com/open-formulieren/open-forms-sdk/pull/717#issuecomment-2405060364
if (!this.component.multiple) {
setErrorAttributes(elements, hasErrors, hasMessages, this.element);
}
return super.setErrorClasses(elements, dirty, hasErrors, hasMessages);
}

Expand Down
6 changes: 5 additions & 1 deletion src/formio/components/Password.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@ class Password extends Formio.Components.components.password {
}

setErrorClasses(elements, dirty, hasErrors, hasMessages) {
setErrorAttributes(elements, hasErrors, hasMessages, this.element);
// setErrorAttributes cannot be done for a `multiple` component
// https://github.com/open-formulieren/open-forms-sdk/pull/717#issuecomment-2405060364
if (!this.component.multiple) {
setErrorAttributes(elements, hasErrors, hasMessages, this.element);
}
return super.setErrorClasses(elements, dirty, hasErrors, hasMessages);
}
}
Expand Down
6 changes: 5 additions & 1 deletion src/formio/components/PhoneNumberField.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,11 @@ class PhoneNumberField extends PhoneNumber {
}

setErrorClasses(elements, dirty, hasErrors, hasMessages) {
setErrorAttributes(elements, hasErrors, hasMessages, this.element);
// setErrorAttributes cannot be done for a `multiple` component
// https://github.com/open-formulieren/open-forms-sdk/pull/717#issuecomment-2405060364
if (!this.component.multiple) {
setErrorAttributes(elements, hasErrors, hasMessages, this.element);
}
return super.setErrorClasses(elements, dirty, hasErrors, hasMessages);
}

Expand Down
6 changes: 5 additions & 1 deletion src/formio/components/TextArea.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@ class TextArea extends Formio.Components.components.textarea {
}

setErrorClasses(elements, dirty, hasErrors, hasMessages) {
setErrorAttributes(elements, hasErrors, hasMessages, this.element);
// setErrorAttributes cannot be done for a `multiple` component
// https://github.com/open-formulieren/open-forms-sdk/pull/717#issuecomment-2405060364
if (!this.component.multiple) {
setErrorAttributes(elements, hasErrors, hasMessages, this.element);
}
return super.setErrorClasses(elements, dirty, hasErrors, hasMessages);
}

Expand Down
6 changes: 5 additions & 1 deletion src/formio/components/TextField.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,11 @@ class TextField extends Formio.Components.components.textfield {
}

setErrorClasses(elements, dirty, hasErrors, hasMessages) {
setErrorAttributes(elements, hasErrors, hasMessages, this.element);
// setErrorAttributes cannot be done for a `multiple` component
// https://github.com/open-formulieren/open-forms-sdk/pull/717#issuecomment-2405060364
if (!this.component.multiple) {
setErrorAttributes(elements, hasErrors, hasMessages, this.element);
}
return super.setErrorClasses(elements, dirty, hasErrors, hasMessages);
}

Expand Down
6 changes: 5 additions & 1 deletion src/formio/components/TimeField.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ class TimeField extends Time {
}

setErrorClasses(elements, dirty, hasErrors, hasMessages) {
setErrorAttributes(elements, hasErrors, hasMessages, this.element);
// setErrorAttributes cannot be done for a `multiple` component
// https://github.com/open-formulieren/open-forms-sdk/pull/717#issuecomment-2405060364
if (!this.component.multiple) {
setErrorAttributes(elements, hasErrors, hasMessages, this.element);
}
return super.setErrorClasses(elements, dirty, hasErrors, hasMessages);
}

Expand Down

0 comments on commit c1196ab

Please sign in to comment.