Skip to content

Commit f83b000

Browse files
kumibrrShaneK
andauthored
fix(header): show iOS condense header when app is in MD mode (#30690)
Issue number: resolves #29929 --------- ## What is the current behavior? When forcing `mode=ios` in a collapsible header, `.header-collapse-condense` would still be applied from the `header.md.scss` file, leaving the collapsible header always hidden. ## What is the new behavior? When forcing `mode=ios` in a collapsible header, the `.header-collapse-condense` styles from the `header.md.scss` file won't be applied, and the collapsible header will be visible. ## Does this introduce a breaking change? - [ ] Yes - [x] No ## Other information Something worth mentioning is that this behavior only appears after initial load: if the route is loaded refreshing the page, the header will appear and work correctly, but navigating forth and back will apply both the .ios and .md style files. I showcase this with a modal because It'll always display the broken hehavior. | Before | After | |--------|-------| | <video src="https://github.com/user-attachments/assets/1307ee9f-452a-4b00-877d-0b8e360d3bf7"> | <video src="https://github.com/user-attachments/assets/f9ee3851-ce94-4a27-9947-37aa1f5433b9"> | --------- Co-authored-by: ShaneK <[email protected]>
1 parent 3b60a1d commit f83b000

File tree

2 files changed

+72
-1
lines changed

2 files changed

+72
-1
lines changed

core/src/components/header/header.md.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
box-shadow: $header-md-box-shadow;
99
}
1010

11-
.header-collapse-condense {
11+
.header-md.header-collapse-condense {
1212
display: none;
1313
}
1414

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
import { expect } from '@playwright/test';
2+
import { configs, test } from '@utils/test/playwright';
3+
4+
/**
5+
* This test verifies that collapsible headers with mode="ios" work correctly
6+
* when both iOS and MD stylesheets are loaded. The bug occurred because
7+
* `.header-collapse-condense { display: none }` in the MD stylesheet was not
8+
* scoped to `.header-md`, causing it to hide iOS condense headers when both
9+
* stylesheets were present.
10+
*/
11+
configs({ modes: ['md'], directions: ['ltr'] }).forEach(({ title, config }) => {
12+
test.describe(title('header: condense with iOS mode override'), () => {
13+
test('should show iOS condense header when both MD and iOS styles are loaded', async ({ page }) => {
14+
test.info().annotations.push({
15+
type: 'issue',
16+
description: 'https://github.com/ionic-team/ionic-framework/issues/29929',
17+
});
18+
19+
// Include both an MD header and an iOS modal to force both stylesheets to load
20+
await page.setContent(
21+
`
22+
<!-- MD header to force MD stylesheet to load -->
23+
<ion-header mode="md" id="mdHeader">
24+
<ion-toolbar>
25+
<ion-title>MD Header</ion-title>
26+
</ion-toolbar>
27+
</ion-header>
28+
29+
<!-- Modal with iOS condense header -->
30+
<ion-modal>
31+
<ion-header mode="ios" id="smallTitleHeader">
32+
<ion-toolbar>
33+
<ion-title>Header</ion-title>
34+
</ion-toolbar>
35+
</ion-header>
36+
<ion-content fullscreen="true">
37+
<ion-header collapse="condense" mode="ios" id="largeTitleHeader">
38+
<ion-toolbar>
39+
<ion-title size="large">Large Header</ion-title>
40+
</ion-toolbar>
41+
</ion-header>
42+
<p>Content</p>
43+
</ion-content>
44+
</ion-modal>
45+
`,
46+
config
47+
);
48+
49+
const modal = page.locator('ion-modal');
50+
const ionModalDidPresent = await page.spyOnEvent('ionModalDidPresent');
51+
52+
await modal.evaluate((el: HTMLIonModalElement) => el.present());
53+
await ionModalDidPresent.next();
54+
55+
const largeTitleHeader = modal.locator('#largeTitleHeader');
56+
57+
// The large title header should be visible, not hidden by MD styles
58+
await expect(largeTitleHeader).toBeVisible();
59+
60+
// Verify it has the iOS mode class
61+
await expect(largeTitleHeader).toHaveClass(/header-ios/);
62+
63+
// Verify it does NOT have display: none applied
64+
// This would fail if the MD stylesheet's unscoped .header-collapse-condense rule applies
65+
const display = await largeTitleHeader.evaluate((el) => {
66+
return window.getComputedStyle(el).display;
67+
});
68+
expect(display).not.toBe('none');
69+
});
70+
});
71+
});

0 commit comments

Comments
 (0)