mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-18 19:21:34 +08:00
fix(segment): clicking disabled button no longer adds ripple to active button (#20254)
fixes #20253
This commit is contained in:
@ -112,13 +112,15 @@ export class Segment implements ComponentInterface {
|
|||||||
onEnd(detail: GestureDetail) {
|
onEnd(detail: GestureDetail) {
|
||||||
this.activated = false;
|
this.activated = false;
|
||||||
|
|
||||||
this.setNextIndex(detail, true);
|
const checkedValidButton = this.setNextIndex(detail, true);
|
||||||
|
|
||||||
detail.event.preventDefault();
|
detail.event.preventDefault();
|
||||||
detail.event.stopImmediatePropagation();
|
detail.event.stopImmediatePropagation();
|
||||||
|
|
||||||
|
if (checkedValidButton) {
|
||||||
this.addRipple(detail);
|
this.addRipple(detail);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private getButtons() {
|
private getButtons() {
|
||||||
return Array.from(this.el.querySelectorAll('ion-segment-button'));
|
return Array.from(this.el.querySelectorAll('ion-segment-button'));
|
||||||
@ -285,8 +287,16 @@ export class Segment implements ComponentInterface {
|
|||||||
current = nextEl;
|
current = nextEl;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!current) {
|
/* tslint:disable-next-line */
|
||||||
return;
|
if (current != null) {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If current element is ion-segment then that means
|
||||||
|
* user tried to select a disabled ion-segment-button,
|
||||||
|
* and we should not update the ripple.
|
||||||
|
*/
|
||||||
|
if (current.tagName === 'ION-SEGMENT') {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (previous !== current) {
|
if (previous !== current) {
|
||||||
@ -294,6 +304,9 @@ export class Segment implements ComponentInterface {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
private emitStyle() {
|
private emitStyle() {
|
||||||
this.ionStyle.emit({
|
this.ionStyle.emit({
|
||||||
'segment': true
|
'segment': true
|
||||||
|
Reference in New Issue
Block a user