-
Notifications
You must be signed in to change notification settings - Fork 394
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
fix: (CXSPA-9010) Previous field error message read. #20071
base: develop
Are you sure you want to change the base?
fix: (CXSPA-9010) Previous field error message read. #20071
Conversation
StanislavSukhanov
commented
Mar 12, 2025
- closes: https://jira.tools.sap/browse/CXSPA-9010
spartacus
|
Project |
spartacus
|
Branch Review |
feature/CXSPA-9010-previous-error-message-is-read-to-user
|
Run status |
|
Run duration | 04m 38s |
Commit |
|
Committer | Stanislav Sukhanov |
View all properties for this run ↗︎ |
Test results | |
---|---|
|
0
|
|
4
|
|
0
|
|
0
|
|
118
|
View all changes introduced in this branch ↗︎ |
@@ -1074,6 +1080,7 @@ export const defaultFeatureToggles: Required<FeatureTogglesInterface> = { | |||
a11yStoreFinderAlerts: true, | |||
a11yStoreFinderLabel: false, | |||
a11yFormErrorMuteIcon: true, | |||
a11yImprovedErrorMessage: true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should introduce this as false
by default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, you are right! Thanks a lot for noticing.
@@ -40,8 +42,22 @@ import { map, startWith } from 'rxjs/operators'; | |||
export class FormErrorsComponent implements DoCheck { | |||
private featureConfigService = inject(FeatureConfigService); | |||
|
|||
private elementRef = inject(ElementRef); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets use protected
here.
constructor(protected ChangeDetectionRef: ChangeDetectorRef) { | ||
useFeatureStyles('a11yFormErrorMuteIcon'); | ||
if (this.featureConfigService.isEnabled('a11yImprovedErrorMessage')) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could move this logic into its own method just to be a little tidier.
if (!ariaLive) { | ||
// If no aria-live value is set add 'polite' as a default. This is preferred over setting | ||
// role='alert' so that screen readers do not interrupt the current task to read this aloud. | ||
this.elementRef.nativeElement.setAttribute('aria-live', 'polite'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should be careful with DOM manipulation on page instantiation because it can cause issues with SSR and hydration. Is it possible to set the attribute using an Angular-friendly method (eg. template, input value)?
https://angular.dev/guide/hydration#direct-dom-manipulation
e65e7fe
to
9aa51c5
Compare
@@ -35,13 +38,24 @@ import { map, startWith } from 'rxjs/operators'; | |||
selector: 'cx-form-errors', | |||
templateUrl: './form-errors.component.html', | |||
changeDetection: ChangeDetectionStrategy.OnPush, | |||
host: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you think we could use @HostBinding
s for these attributes like you did for attr.role
? I think it could be easier to understand and modify.