mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-11-08 15:51:16 +08:00
fix(range): properly display stacked labels in an item with a range (#21944)
fixes #21625
This commit is contained in:
@ -16,6 +16,8 @@ import { createColorClasses } from '../../utils/theme';
|
||||
scoped: true
|
||||
})
|
||||
export class Label implements ComponentInterface {
|
||||
private inRange = false;
|
||||
|
||||
@Element() el!: HTMLElement;
|
||||
|
||||
/**
|
||||
@ -39,6 +41,7 @@ export class Label implements ComponentInterface {
|
||||
@State() noAnimate = false;
|
||||
|
||||
componentWillLoad() {
|
||||
this.inRange = !!this.el.closest('ion-range');
|
||||
this.noAnimate = (this.position === 'floating');
|
||||
this.emitStyle();
|
||||
}
|
||||
@ -57,11 +60,17 @@ export class Label implements ComponentInterface {
|
||||
}
|
||||
|
||||
private emitStyle() {
|
||||
const position = this.position;
|
||||
this.ionStyle.emit({
|
||||
'label': true,
|
||||
[`label-${position}`]: position !== undefined
|
||||
});
|
||||
const { inRange, position } = this;
|
||||
|
||||
// If the label is inside of a range we don't want
|
||||
// to override the classes added by the label that
|
||||
// is a direct child of the item
|
||||
if (!inRange) {
|
||||
this.ionStyle.emit({
|
||||
'label': true,
|
||||
[`label-${position}`]: position !== undefined
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
|
||||
Reference in New Issue
Block a user