AAE-46434 Fix read-only field styling on forms (#11928)

This commit is contained in:
David Olson
2026-06-02 08:54:26 -05:00
committed by GitHub
parent e52b63eaf9
commit aa2a357fb2
10 changed files with 75 additions and 21 deletions
@@ -1,4 +1,5 @@
/* stylelint-disable selector-class-pattern */ /* stylelint-disable selector-class-pattern */
@use '@angular/material' as mat;
@use '../../styles/flex' as flex; @use '../../styles/flex' as flex;
@use '../../styles/mat-selectors' as ms; @use '../../styles/mat-selectors' as ms;
@@ -274,3 +275,49 @@
form-field { form-field {
width: 100%; width: 100%;
} }
.adf-readonly {
@include mat.form-field-overrides(
(
filled-disabled-input-text-color: var(--mat-sys-on-surface),
filled-disabled-label-text-color: var(--mat-sys-on-surface-variant),
filled-active-indicator-color: color-mix(in srgb, var(--mat-sys-on-surface) 6%, transparent),
filled-hover-active-indicator-color: color-mix(in srgb, var(--mat-sys-on-surface) 6%, transparent),
outlined-disabled-input-text-color: var(--mat-sys-on-surface),
outlined-disabled-label-text-color: var(--mat-sys-on-surface-variant),
outlined-outline-color: color-mix(in srgb, var(--mat-sys-on-surface) 6%, transparent),
outlined-hover-outline-color: color-mix(in srgb, var(--mat-sys-on-surface) 6%, transparent)
)
);
@include mat.select-overrides(
(
disabled-trigger-text-color: var(--mat-sys-on-surface)
)
);
@include mat.checkbox-overrides(
(
disabled-label-color: var(--mat-sys-on-surface),
disabled-selected-checkmark-color: var(--mat-sys-surface),
disabled-selected-icon-color: var(--mat-sys-outline)
)
);
@include mat.radio-overrides(
(
disabled-label-color: var(--mat-sys-on-surface),
disabled-selected-icon-color: var(--mat-sys-primary)
)
);
@include mat.button-overrides(
(
filled-disabled-label-text-color: var(--mat-sys-on-surface)
)
);
.mat-datepicker-toggle.mat-mdc-button-disabled {
color: var(--mat-sys-on-surface-variant);
}
.mat-mdc-chip-disabled {
opacity: 1;
}
}
@@ -1,10 +1,12 @@
<button <div [class.adf-readonly]="field?.readOnly">
mat-flat-button <button
class="adf-button-widget__button" mat-flat-button
[matTooltip]="field?.tooltip" class="adf-button-widget__button"
[matTooltipShowDelay]="tooltipShowDelay" [matTooltip]="field?.tooltip"
[disabled]="field?.readOnly ?? false" [matTooltipShowDelay]="tooltipShowDelay"
(click)="onClick($event)" [disabled]="field?.readOnly ?? false"
> (click)="onClick($event)"
{{ field?.name | translate }} >
</button> {{ field?.name | translate }}
</button>
</div>
@@ -1,5 +1,7 @@
<div [ngClass]="field.className" <div [ngClass]="field.className"
[class.adf-invalid]="!field.isValid && isTouched()" class="adf-checkbox-widget-container" [class.adf-invalid]="!field.isValid && isTouched()"
[class.adf-readonly]="field.readOnly || readOnly"
class="adf-checkbox-widget-container"
> >
<mat-checkbox [id]="field.id" <mat-checkbox [id]="field.id"
class="adf-checkbox" class="adf-checkbox"
@@ -1,6 +1,7 @@
<div class="{{ field.className }}" <div class="{{ field.className }}"
id="data-time-widget" id="data-time-widget"
[class.adf-invalid]="datetimeInputControl.invalid && datetimeInputControl.touched" [class.adf-invalid]="datetimeInputControl.invalid && datetimeInputControl.touched"
[class.adf-readonly]="field.readOnly"
[class.adf-left-label-input-container]="field.leftLabels"> [class.adf-left-label-input-container]="field.leftLabels">
<div *ngIf="field.leftLabels"> <div *ngIf="field.leftLabels">
<label class="adf-label adf-left-label" [attr.for]="field.id"> <label class="adf-label adf-left-label" [attr.for]="field.id">
@@ -1,4 +1,6 @@
<div class="{{ field.className }} date-widget-container" id="data-widget" [class.adf-invalid]="dateInputControl.invalid && dateInputControl.touched"> <div class="{{ field.className }} date-widget-container" id="data-widget"
[class.adf-invalid]="dateInputControl.invalid && dateInputControl.touched"
[class.adf-readonly]="field.readOnly">
<mat-form-field class="adf-date-widget adf-form-field-input" [floatLabel]="field.placeholder ? 'always' : null"> <mat-form-field class="adf-date-widget adf-form-field-input" [floatLabel]="field.placeholder ? 'always' : null">
<mat-label class="adf-label" <mat-label class="adf-label"
[id]="field.id + '-label'" [id]="field.id + '-label'"
@@ -21,13 +21,13 @@
.adf-readonly { .adf-readonly {
.adf-container-widget { .adf-container-widget {
&-repeat__text { &-repeat__text {
color: var(--mdc-text-button-disabled-label-text-color, color-mix(in srgb, var(--mat-sys-on-surface) 38%, transparent)); color: var(--mat-sys-on-surface);
border-bottom: 1px solid var(--mdc-text-button-disabled-label-text-color, color-mix(in srgb, var(--mat-sys-on-surface) 38%, transparent)); border-bottom: 1px solid var(--mat-sys-outline-variant);
cursor: default; cursor: default;
} }
&-row-limit { &-row-limit {
color: var(--mdc-text-button-disabled-label-text-color, color-mix(in srgb, var(--mat-sys-on-surface) 38%, transparent)); color: var(--mat-sys-on-surface-variant);
font-size: 12px; font-size: 12px;
} }
} }
@@ -2,6 +2,7 @@
class="{{field.className}}" class="{{field.className}}"
id="data-widget" id="data-widget"
[class.adf-invalid]="dateInputControl.invalid && dateInputControl.touched" [class.adf-invalid]="dateInputControl.invalid && dateInputControl.touched"
[class.adf-readonly]="field.readOnly"
[class.adf-left-label-input-container]="field.leftLabels" [class.adf-left-label-input-container]="field.leftLabels"
> >
<div *ngIf="field.leftLabels"> <div *ngIf="field.leftLabels">
@@ -1,7 +1,7 @@
<form> <form>
<mat-form-field class="adf-cloud-group adf-form-field-input" [class.adf-invalid]="hasError() && isDirty()"> <mat-form-field class="adf-cloud-group adf-form-field-input" [class.adf-invalid]="hasError() && isDirty()">
@if (label || required) { <mat-label><span>{{label}}</span></mat-label> } @if (label || required) { <mat-label><span>{{label}}</span></mat-label> }
<mat-chip-grid [required]="required" #groupChipList data-automation-id="adf-cloud-group-chip-list"> <mat-chip-grid [required]="required" [disabled]="isReadonly()" #groupChipList data-automation-id="adf-cloud-group-chip-list">
<mat-chip-row <mat-chip-row
*ngFor="let group of selectedGroups" *ngFor="let group of selectedGroups"
[removable]="!(group.readonly)" [removable]="!(group.readonly)"
@@ -16,7 +16,7 @@
[formControl]="searchGroupsControl" [formControl]="searchGroupsControl"
[matAutocomplete]="auto" [matAutocomplete]="auto"
[matChipInputFor]="groupChipList" [matChipInputFor]="groupChipList"
[placeholder]="title | translate" [placeholder]="isReadonly() ? '' : (title | translate)"
[required]="required" [required]="required"
(focus)="setFocus(true)" (focus)="setFocus(true)"
(blur)="setFocus(false); markAsTouched()" (blur)="setFocus(false); markAsTouched()"
@@ -173,9 +173,6 @@ export class GroupCloudComponent implements OnInit, OnChanges {
} }
ngOnChanges(changes: SimpleChanges): void { ngOnChanges(changes: SimpleChanges): void {
if (changes?.readOnly || changes?.validate) {
this.updateSearchControlState();
}
if (this.hasPreselectedGroupsChanged(changes) || this.hasModeChanged(changes) || this.isValidationChanged(changes)) { if (this.hasPreselectedGroupsChanged(changes) || this.hasModeChanged(changes) || this.isValidationChanged(changes)) {
if (this.hasPreSelectGroups()) { if (this.hasPreSelectGroups()) {
this.loadPreSelectGroups(); this.loadPreSelectGroups();
@@ -188,6 +185,8 @@ export class GroupCloudComponent implements OnInit, OnChanges {
this.invalidGroups = []; this.invalidGroups = [];
} }
} }
this.updateSearchControlState();
} }
private initSearch(): void { private initSearch(): void {
@@ -9,7 +9,7 @@
</mat-label> </mat-label>
<mat-label *ngIf="title">{{ title | translate }}</mat-label> <mat-label *ngIf="title">{{ title | translate }}</mat-label>
<mat-chip-grid [required]="required" #userMultipleChipList data-automation-id="adf-cloud-people-chip-list"> <mat-chip-grid [required]="required" [disabled]="isReadonly()" #userMultipleChipList data-automation-id="adf-cloud-people-chip-list">
<mat-chip-row <mat-chip-row
*ngFor="let user of selectedUsers" *ngFor="let user of selectedUsers"
[removable]="!user.readonly" [removable]="!user.readonly"