Skip to content

Commit ae1325c

Browse files
authoredSep 16, 2021
fix(label): only inherit color if color property is set on ion-item (#23944)
resolves #20125
1 parent 8108edd commit ae1325c

File tree

5 files changed

+43
-4
lines changed

5 files changed

+43
-4
lines changed
 

‎core/src/components/label/label.ios.scss

+1-2
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,10 @@
8989
color: #{$item-ios-paragraph-text-color};
9090
}
9191

92-
:host-context(.ion-color)::slotted(p) {
92+
:host(.in-item-color)::slotted(p) {
9393
color: inherit;
9494
}
9595

96-
9796
::slotted(*) h2:last-child,
9897
::slotted(*) h3:last-child,
9998
::slotted(*) h4:last-child,

‎core/src/components/label/label.md.scss

+1-1
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,6 @@
104104
color: $item-md-paragraph-text-color;
105105
}
106106

107-
:host-context(.ion-color)::slotted(p) {
107+
:host(.in-item-color)::slotted(p) {
108108
color: inherit;
109109
}

‎core/src/components/label/label.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Component, ComponentInterface, Element, Event, EventEmitter, Host, Prop
22

33
import { getIonMode } from '../../global/ionic-global';
44
import { Color, StyleEventDetail } from '../../interface';
5-
import { createColorClasses } from '../../utils/theme';
5+
import { createColorClasses, hostContext } from '../../utils/theme';
66

77
/**
88
* @virtualProp {"ios" | "md"} mode - The mode determines which platform styles to use.
@@ -101,6 +101,7 @@ export class Label implements ComponentInterface {
101101
<Host
102102
class={createColorClasses(this.color, {
103103
[mode]: true,
104+
'in-item-color': hostContext('ion-item.ion-color', this.el),
104105
[`label-${position}`]: position !== undefined,
105106
[`label-no-animate`]: (this.noAnimate)
106107
})}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { newE2EPage } from '@stencil/core/testing';
2+
3+
test('label: color', async () => {
4+
const page = await newE2EPage({
5+
url: '/src/components/label/test/color?ionic:_testing=true'
6+
});
7+
8+
const compare = await page.compareScreenshot();
9+
expect(compare).toMatchScreenshot();
10+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<!DOCTYPE html>
2+
<html lang="en" dir="ltr">
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>Label - Color</title>
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no, viewport-fit=cover">
7+
<link href="../../../../../css/ionic.bundle.css" rel="stylesheet">
8+
<link href="../../../../../scripts/testing/styles.css" rel="stylesheet">
9+
<script src="../../../../../scripts/testing/scripts.js"></script>
10+
<script nomodule src="../../../../../dist/ionic/ionic.js"></script>
11+
<script type="module" src="../../../../../dist/ionic/ionic.esm.js"></script>
12+
</head>
13+
14+
<body>
15+
<ion-app>
16+
<ion-header>
17+
<ion-toolbar>
18+
<ion-title>Label - Color</ion-title>
19+
</ion-toolbar>
20+
</ion-header>
21+
22+
<ion-content color="light">
23+
<ion-item>
24+
<ion-label>Label Text<p>This paragraph should not inherit the color from content</p></ion-label>
25+
</ion-item>
26+
</ion-content>
27+
</ion-app>
28+
</body>
29+
</html>

0 commit comments

Comments
 (0)