-
-
Notifications
You must be signed in to change notification settings - Fork 9
fix: refresh native controls after foreground and viewport changes #233
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
2d88176
fix: refresh native controls after foreground and layout changes
rdlabo 35a6f4e
fix: use system search presentation in vertical bars
rdlabo a9e07b3
fix: restore search tabs after keyboard rotation
rdlabo 0026744
test: align geometry rejection check with resize refresh
rdlabo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -421,35 +421,121 @@ test('standalone Vertical Control Area never snapshots ordinary Native UI Shell | |
| .toBe(true); | ||
| }); | ||
|
|
||
| test('standalone vertical bars keep searchable tabs usable on the Web', async ({ page }) => { | ||
| await mockNative(page); | ||
| await page.route('https://picsum.photos/**', (route) => route.abort()); | ||
| await page.goto('/main/album?verticalBarsOnly=1'); | ||
| await page.locator('ion-app').evaluate((element) => element.classList.add('ios-theme-vertical-bars')); | ||
| await expect | ||
| .poll(() => | ||
| for (const standalone of [false, true]) { | ||
| test(`vertical native search preserves rail tabs (${standalone ? 'standalone' : 'full shell'})`, async ({ page }) => { | ||
| await mockNative(page); | ||
| await page.route('https://picsum.photos/**', (route) => route.abort()); | ||
| await page.goto(`/main/album${standalone ? '?verticalBarsOnly=1' : ''}`); | ||
| await page.locator('ion-app').evaluate((element) => element.classList.add('ios-theme-vertical-bars')); | ||
| const footer = page.locator('app-album-page ion-footer'); | ||
| const fab = page.locator('app-album-page ion-fab'); | ||
| const tabs = page.locator('ion-tab-bar'); | ||
| const config = () => | ||
| page.evaluate(() => | ||
| Capacitor.registerPlugin<ShellMock>('IonicNativeUIShell') | ||
| .updates.at(-1) | ||
| ?.controls.some((control: ShellControl) => control.placement === 'vertical-bars'), | ||
| ), | ||
| ) | ||
| .toBe(true); | ||
| // The rail has no search surface, so no control may carry a search payload. | ||
| await expect | ||
| .poll(() => | ||
| page.evaluate(() => | ||
| Capacitor.registerPlugin<ShellMock>('IonicNativeUIShell') | ||
| .updates.at(-1)! | ||
| .controls.every((control: ShellControl) => !control.search), | ||
| ), | ||
| ) | ||
| .toBe(true); | ||
| // The Web search trigger and footer stay visible and interactive. | ||
| const fab = page.locator('app-album-page ion-fab'); | ||
| await expect(fab).toBeVisible(); | ||
| await expect(fab).not.toHaveAttribute('data-native-ui-shell'); | ||
| await expect(page.locator('app-album-page ion-footer')).toBeVisible(); | ||
| ?.controls.find((control: ShellControl) => control.placement === 'vertical-bars' && control.search), | ||
| ); | ||
| await expect.poll(config).toBeTruthy(); | ||
| await expect(footer).toHaveAttribute('data-native-ui-shell', ''); | ||
| await expect(fab).toHaveAttribute('data-native-ui-shell', ''); | ||
| const tabState = (control: ShellControl) => control.items.map(({ id, selected }) => ({ id, selected })); | ||
| const items = tabState((await config())!); | ||
| await page.evaluate(() => { | ||
| const state = Capacitor.registerPlugin<ShellMock>('IonicNativeUIShell'); | ||
| const snapshot = state.updates.at(-1)!; | ||
| const search = snapshot.controls.find((control: ShellControl) => control.search)!.search!; | ||
| state.notifyListeners('activate', { id: search.trigger.id, revision: snapshot.revision, sequence: ++state.sequence }); | ||
| }); | ||
| await expect.poll(async () => (await config())?.search?.active).toBe(true); | ||
| expect(tabState((await config())!)).toEqual(items); | ||
| await expect(tabs).toHaveAttribute('data-native-ui-shell', ''); | ||
| // Native enter must bypass the Web search morph. | ||
| await expect(footer).toHaveCSS('opacity', '0'); | ||
| await expect(tabs).toHaveCSS('opacity', '1'); | ||
| await page.evaluate(() => { | ||
| const state = Capacitor.registerPlugin<ShellMock>('IonicNativeUIShell'); | ||
| const snapshot = state.updates.at(-1)!; | ||
| const search = snapshot.controls.find((control: ShellControl) => control.search)!.search!; | ||
| state.notifyListeners('search', { | ||
| id: search.id, | ||
| phase: 'input', | ||
| value: 'native query', | ||
| composing: false, | ||
| valueVersion: search.valueVersion, | ||
| revision: snapshot.revision, | ||
| sequence: ++state.sequence, | ||
| }); | ||
| }); | ||
| await expect.poll(() => footer.locator('ion-searchbar').evaluate((bar: HTMLIonSearchbarElement) => bar.value)).toBe('native query'); | ||
| await page.evaluate(() => { | ||
| const state = Capacitor.registerPlugin<ShellMock>('IonicNativeUIShell'); | ||
| const snapshot = state.updates.at(-1)!; | ||
| const search = snapshot.controls.find((control: ShellControl) => control.search)!.search!; | ||
| state.notifyListeners('activate', { id: search.closeId, revision: snapshot.revision, sequence: ++state.sequence }); | ||
| }); | ||
| await expect.poll(async () => (await config())?.search?.active).toBe(false); | ||
| await expect(tabs).toHaveAttribute('data-native-ui-shell', ''); | ||
| expect(tabState((await config())!)).toEqual(items); | ||
| // Late icon hydration must not add the Web close button to the native rail. | ||
| await footer.locator('ion-buttons[slot=start] ion-icon').evaluate((icon) => icon.setAttribute('name', 'close')); | ||
| for (let cycle = 0; cycle < 3; cycle++) { | ||
| await page.evaluate(() => { | ||
| const state = Capacitor.registerPlugin<ShellMock>('IonicNativeUIShell'); | ||
| const snapshot = state.updates.at(-1)!; | ||
| const search = snapshot.controls.find((control: ShellControl) => control.search)!.search!; | ||
| state.notifyListeners('activate', { id: search.trigger.id, revision: snapshot.revision, sequence: ++state.sequence }); | ||
| }); | ||
| await expect.poll(async () => (await config())?.search?.active).toBe(true); | ||
| await footer.locator('ion-searchbar').evaluate((bar: HTMLIonSearchbarElement) => bar.setFocus()); | ||
| await expect.poll(async () => (await config())?.search?.focused).toBe(true); | ||
| await page.evaluate(() => { | ||
| const state = Capacitor.registerPlugin<ShellMock>('IonicNativeUIShell'); | ||
| const snapshot = state.updates.at(-1)!; | ||
| const search = snapshot.controls.find((control: ShellControl) => control.search)!.search!; | ||
| state.notifyListeners('activate', { id: search.closeId, revision: snapshot.revision, sequence: ++state.sequence }); | ||
| }); | ||
| await expect.poll(async () => (await config())?.search?.active).toBe(false); | ||
| expect(tabState((await config())!)).toEqual(items); | ||
| } | ||
| await activate(page, 'Index'); | ||
| await activate(page, 'Library'); | ||
| await expect.poll(async () => (await config())?.search?.available).toBe(true); | ||
| }); | ||
| } | ||
|
|
||
| test('vertical Web tabs remain visible while searching without a native rail', async ({ page }) => { | ||
| await mockNative(page, false, null); | ||
| await page.route('https://picsum.photos/**', (route) => route.abort()); | ||
| await page.goto('/main/album?verticalBarsOnly=1'); | ||
| await page.locator('ion-app').evaluate((element) => element.classList.add('ios-theme-vertical-bars')); | ||
| const tabs = page.locator('ion-tab-bar'); | ||
| await expect(tabs).not.toHaveAttribute('data-native-ui-shell'); | ||
| await page.locator('app-album-page ion-fab-button').click(); | ||
| const footer = page.locator('app-album-page ion-footer'); | ||
| await expect(footer).toHaveCSS('opacity', '1'); | ||
| await tabs.evaluate((element) => element.classList.add('tab-bar-hidden')); | ||
| await expect(tabs).toBeVisible(); | ||
| await expect(tabs).toHaveCSS('opacity', '1'); | ||
| await expect(tabs.locator('ion-tab-button.tab-selected')).toBeVisible(); | ||
| await expect(tabs.locator('ion-tab-button').first()).toHaveCSS('opacity', '1'); | ||
| await footer.locator('ion-buttons[slot=start] ion-button').click(); | ||
| await expect(footer).toHaveCSS('opacity', '0'); | ||
| await expect(tabs).toHaveCSS('opacity', '1'); | ||
| let bounds: { x: number; width: number } | undefined; | ||
| for (let cycle = 0; cycle < 3; cycle++) { | ||
| await page.locator('app-album-page ion-fab-button').click(); | ||
| await expect(footer).toHaveCSS('opacity', '1'); | ||
| const frame = await footer.locator('ion-searchbar').evaluate((bar) => { | ||
| const { x, width } = bar.getBoundingClientRect(); | ||
| return { x, width }; | ||
| }); | ||
| if (bounds) expect(frame).toEqual(bounds); | ||
| bounds = frame; | ||
| await footer.locator('ion-buttons[slot=start] ion-button').click(); | ||
| await expect(footer).toHaveCSS('opacity', '0'); | ||
| await expect(tabs).toHaveCSS('opacity', '1'); | ||
| } | ||
| }); | ||
|
|
||
| test('verticalBars back navigation and toolbar slots request native rail placement', async ({ page }) => { | ||
|
|
@@ -1242,6 +1328,29 @@ test('delayed response cannot reclaim a hidden source', async ({ page }) => { | |
| .toBe(false); | ||
| }); | ||
|
|
||
| for (const event of ['foreground', 'window-resize', 'visual-viewport-resize'] as const) { | ||
| test(`${event} restores native tabs even when the control snapshot is unchanged`, async ({ page }) => { | ||
| await mockNative(page); | ||
| await page.goto('/main/index'); | ||
| await expect(page.locator('ion-tab-bar')).toHaveAttribute('data-native-ui-shell', ''); | ||
| // Wait for the selected-tab icon animation to finish before comparing snapshots. | ||
| await page.waitForTimeout(750); | ||
| const previous = await page.evaluate((event) => { | ||
| const snapshot = Capacitor.registerPlugin<ShellMock>('IonicNativeUIShell').updates.at(-1)!; | ||
| if (event === 'foreground') document.dispatchEvent(new Event('visibilitychange')); | ||
| else if (event === 'window-resize') window.dispatchEvent(new Event('resize')); | ||
| else window.visualViewport!.dispatchEvent(new Event('resize')); | ||
|
Comment on lines
+1341
to
+1342
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| return snapshot; | ||
| }, event); | ||
| await expect | ||
| .poll(() => page.evaluate(() => Capacitor.registerPlugin<ShellMock>('IonicNativeUIShell').updates.at(-1)!.revision)) | ||
| .toBeGreaterThan(previous.revision); | ||
| const restored = await page.evaluate(() => Capacitor.registerPlugin<ShellMock>('IonicNativeUIShell').updates.at(-1)!); | ||
| expect(restored.controls).toEqual(previous.controls); | ||
| await expect(page.locator('ion-tab-bar')).toHaveAttribute('data-native-ui-shell', ''); | ||
| }); | ||
| } | ||
|
|
||
| test('native refresh during a pending acknowledgement resends unchanged controls', async ({ page }) => { | ||
| await mockNative(page); | ||
| await page.goto('/main/index/native-ui-shell'); | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔍 前景復帰テストは非表示期間を再現しない
表示中の document に visibilitychange を送るため、非表示時の検索終了と復帰後の表示回復は通らない。実機のバックグラウンド復帰も確認したい。
Was this helpful? React with 👍 or 👎 to provide feedback.