fix(many): disabled control in item does not receive active/hover states (#26867)

Resolves #26706
This commit is contained in:
Sean Perkins
2023-03-14 10:32:55 -04:00
committed by GitHub
parent ef33270b55
commit f829672a6a
6 changed files with 73 additions and 31 deletions

View File

@ -150,23 +150,22 @@ export class Checkbox implements ComponentInterface {
} }
@Watch('checked') @Watch('checked')
checkedChanged() {
this.emitStyle();
}
@Watch('disabled') @Watch('disabled')
disabledChanged() { protected styleChanged() {
this.emitStyle(); this.emitStyle();
} }
// TODO(FW-3100): remove this
private emitStyle() { private emitStyle() {
const style: StyleEventDetail = {
'interactive-disabled': this.disabled,
};
// TODO(FW-3100): remove this
if (this.legacyFormController.hasLegacyControl()) { if (this.legacyFormController.hasLegacyControl()) {
this.ionStyle.emit({ style['checkbox-checked'] = this.checked;
'checkbox-checked': this.checked,
'interactive-disabled': this.disabled,
});
} }
this.ionStyle.emit(style);
} }
private setFocus() { private setFocus() {

View File

@ -136,6 +136,18 @@
</ion-list> </ion-list>
</div> </div>
</div> </div>
<h1>States</h1>
<div class="grid">
<div class="grid-item">
<h2>Disabled</h2>
<ion-list>
<ion-item>
<ion-checkbox disabled="true">Enable Notifications</ion-checkbox>
</ion-item>
</ion-list>
</div>
</div>
</ion-content> </ion-content>
</ion-app> </ion-app>
</body> </body>

View File

@ -164,16 +164,23 @@ export class Radio implements ComponentInterface {
} }
} }
@Watch('color')
@Watch('checked') @Watch('checked')
@Watch('color')
@Watch('disabled') @Watch('disabled')
emitStyle() { protected styleChanged() {
this.emitStyle();
}
private emitStyle() {
const style: StyleEventDetail = {
'interactive-disabled': this.disabled,
};
if (this.legacyFormController.hasLegacyControl()) { if (this.legacyFormController.hasLegacyControl()) {
this.ionStyle.emit({ style['radio-checked'] = this.checked;
'radio-checked': this.checked,
'interactive-disabled': this.disabled,
});
} }
this.ionStyle.emit(style);
} }
private updateState = () => { private updateState = () => {

View File

@ -154,6 +154,17 @@
</ion-list> </ion-list>
</div> </div>
</div> </div>
<h1>States</h1>
<div class="grid">
<ion-list>
<ion-radio-group>
<ion-item>
<ion-radio disabled="true">Enable Notifications</ion-radio>
</ion-item>
</ion-radio-group>
</ion-list>
</div>
</ion-content> </ion-content>
</ion-app> </ion-app>
</body> </body>

View File

@ -214,14 +214,10 @@ export class Select implements ComponentInterface {
@Event() ionStyle!: EventEmitter<StyleEventDetail>; @Event() ionStyle!: EventEmitter<StyleEventDetail>;
@Watch('disabled') @Watch('disabled')
@Watch('placeholder')
@Watch('isExpanded') @Watch('isExpanded')
styleChanged() { @Watch('placeholder')
this.emitStyle();
}
@Watch('value') @Watch('value')
valueChanged() { protected styleChanged() {
this.emitStyle(); this.emitStyle();
} }
@ -653,17 +649,21 @@ export class Select implements ComponentInterface {
} }
private emitStyle() { private emitStyle() {
const { disabled } = this;
const style: StyleEventDetail = {
'interactive-disabled': disabled,
};
if (this.legacyFormController.hasLegacyControl()) { if (this.legacyFormController.hasLegacyControl()) {
this.ionStyle.emit({ style['interactive'] = true;
interactive: true, style['select'] = true;
'interactive-disabled': this.disabled, style['select-disabled'] = disabled;
select: true, style['has-placeholder'] = this.placeholder !== undefined;
'select-disabled': this.disabled, style['has-value'] = this.hasValue();
'has-placeholder': this.placeholder !== undefined, style['has-focus'] = this.isExpanded;
'has-value': this.hasValue(),
'has-focus': this.isExpanded,
});
} }
this.ionStyle.emit(style);
} }
private onClick = (ev: UIEvent) => { private onClick = (ev: UIEvent) => {

View File

@ -19,6 +19,7 @@
grid-row-gap: 20px; grid-row-gap: 20px;
grid-column-gap: 20px; grid-column-gap: 20px;
} }
h2 { h2 {
font-size: 12px; font-size: 12px;
font-weight: normal; font-weight: normal;
@ -27,6 +28,7 @@
margin-top: 10px; margin-top: 10px;
} }
@media screen and (max-width: 800px) { @media screen and (max-width: 800px) {
.grid { .grid {
grid-template-columns: 1fr; grid-template-columns: 1fr;
@ -67,6 +69,17 @@
</ion-item> </ion-item>
</ion-list> </ion-list>
</div> </div>
<div class="grid-item">
<h2>Disabled</h2>
<ion-list>
<ion-item>
<ion-select label="Fruit" value="apple" disabled="true">
<ion-select-option value="apple">Apple</ion-select-option>
</ion-select>
</ion-item>
</ion-list>
</div>
</div> </div>
</ion-content> </ion-content>
</ion-app> </ion-app>