-
Notifications
You must be signed in to change notification settings - Fork 13.4k
fix(footer): remove toolbar bottom padding if near bottom slot tabs or keyboard is open #25746
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
20 commits
Select commit
Hold shift + click to select a range
fcb04fc
fix(footer): remove bottom padding if near bottom slot tabs or keyboa…
814ea0b
test(footer): add with-tabs test
c88e6cb
chore(): add updated snapshots
Ionitron b868ba8
chore(): lint
3f4baf9
chore(footer): explicitly limit padding fix to bottom slot
33d9cb0
refactor(footer, tab-bar): pull keyboard logic into separate util
17041f9
chore(footer): make state var private
4b8b153
fix(keyboard-controller): use win util
b7ae897
chore(footer): clean up code
43b74fd
Merge branch 'main' into FW-1925
averyrousseau 3f7959e
chore(): lint
8a8d283
fix(): don't use @utils in imports
32c6668
test(footer): skip RTL in tabs test
4fa5325
refactor(keyboard-controller): init automatically
466bf4d
chore(): lint
17990c6
Merge branch 'main' into FW-1925
averyrousseau fb15079
fix(keyboard-controller): add return type
080b32c
chore(): lint
69f28a2
test(keyboard-controller): add spec tests
1c6c37e
Merge branch 'main' into FW-1925
averyrousseau 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
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 |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| import { expect } from '@playwright/test'; | ||
| import { test } from '@utils/test/playwright'; | ||
|
|
||
| test.describe('footer: with tabs', () => { | ||
| test('should not have extra padding when near a tab bar', async ({ page }, testInfo) => { | ||
| test.skip(testInfo.project.metadata.rtl === true, 'This does not test LTR vs. RTL layout.'); | ||
|
|
||
| await page.goto('/src/components/footer/test/with-tabs'); | ||
|
averyrousseau marked this conversation as resolved.
|
||
|
|
||
| const footer = page.locator('[tab="tab-one"] ion-footer'); | ||
| expect(await footer.screenshot()).toMatchSnapshot(`footer-with-tabs-${page.getSnapshotSettings()}.png`); | ||
|
liamdebeasi marked this conversation as resolved.
|
||
| }); | ||
| }); | ||
Binary file added
BIN
+3.49 KB
...h-tabs/footer.e2e.ts-snapshots/footer-with-tabs-ios-ltr-Mobile-Chrome-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.81 KB
...-tabs/footer.e2e.ts-snapshots/footer-with-tabs-ios-ltr-Mobile-Firefox-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+3.42 KB
...h-tabs/footer.e2e.ts-snapshots/footer-with-tabs-ios-ltr-Mobile-Safari-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+3.85 KB
...th-tabs/footer.e2e.ts-snapshots/footer-with-tabs-md-ltr-Mobile-Chrome-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.96 KB
...h-tabs/footer.e2e.ts-snapshots/footer-with-tabs-md-ltr-Mobile-Firefox-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+3.74 KB
...th-tabs/footer.e2e.ts-snapshots/footer-with-tabs-md-ltr-Mobile-Safari-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| <!DOCTYPE html> | ||
| <html lang="en" dir="ltr"> | ||
| <head> | ||
| <meta charset="UTF-8" /> | ||
| <title>Footer - With Tabs</title> | ||
| <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" | ||
| /> | ||
| <link href="../../../../../css/ionic.bundle.css" rel="stylesheet" /> | ||
| <link href="../../../../../scripts/testing/styles.css" rel="stylesheet" /> | ||
| <script src="../../../../../scripts/testing/scripts.js"></script> | ||
| <script nomodule src="../../../../../dist/ionic/ionic.js"></script> | ||
| <script type="module" src="../../../../../dist/ionic/ionic.esm.js"></script> | ||
| <style> | ||
| :root { | ||
| --ion-safe-area-bottom: 40px; | ||
| } | ||
| </style> | ||
| </head> | ||
|
|
||
| <body> | ||
| <ion-app> | ||
| <ion-tabs> | ||
| <ion-tab tab="tab-one"> | ||
| <ion-header> | ||
| <ion-toolbar> | ||
| <ion-title>Tab One</ion-title> | ||
| </ion-toolbar> | ||
| </ion-header> | ||
| <ion-content class="ion-padding"> | ||
| <h1>Tab One</h1> | ||
| </ion-content> | ||
| <ion-footer> | ||
| <ion-toolbar> | ||
| <ion-title>Footer</ion-title> | ||
| </ion-toolbar> | ||
| </ion-footer> | ||
| </ion-tab> | ||
|
|
||
| <ion-tab tab="tab-two"> | ||
| <ion-header> | ||
| <ion-toolbar> | ||
| <ion-title>Tab Two</ion-title> | ||
| </ion-toolbar> | ||
| </ion-header> | ||
| <ion-content class="ion-padding"> | ||
| <h1>Tab Two</h1> | ||
| </ion-content> | ||
| <ion-footer> | ||
| <ion-toolbar> | ||
| <ion-title>Footer</ion-title> | ||
| </ion-toolbar> | ||
| </ion-footer> | ||
| </ion-tab> | ||
|
|
||
| <ion-tab-bar slot="bottom"> | ||
| <ion-tab-button tab="tab-one"> | ||
| <ion-label>Tab One</ion-label> | ||
| <ion-icon name="star"></ion-icon> | ||
| </ion-tab-button> | ||
|
|
||
| <ion-tab-button tab="tab-two"> | ||
| <ion-label>Tab Two</ion-label> | ||
| <ion-icon name="globe"></ion-icon> | ||
| </ion-tab-button> | ||
| </ion-tab-bar> | ||
| </ion-tabs> | ||
| </ion-app> | ||
| </body> | ||
| </html> |
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 |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| import { win } from '../window'; | ||
|
|
||
| /** | ||
| * Creates a controller that tracks and reacts to opening or closing the keyboard. | ||
| * | ||
| * @internal | ||
| * @param keyboardChangeCallback A function to call when the keyboard opens or closes. | ||
| */ | ||
| export const createKeyboardController = ( | ||
| keyboardChangeCallback?: (keyboardOpen: boolean) => void | ||
| ): KeyboardController => { | ||
| let keyboardWillShowHandler: (() => void) | undefined; | ||
| let keyboardWillHideHandler: (() => void) | undefined; | ||
| let keyboardVisible: boolean; | ||
|
|
||
| const init = () => { | ||
| keyboardWillShowHandler = () => { | ||
| keyboardVisible = true; | ||
| if (keyboardChangeCallback) keyboardChangeCallback(true); | ||
| }; | ||
|
|
||
| keyboardWillHideHandler = () => { | ||
| keyboardVisible = false; | ||
| if (keyboardChangeCallback) keyboardChangeCallback(false); | ||
| }; | ||
|
|
||
| win?.addEventListener('keyboardWillShow', keyboardWillShowHandler); | ||
| win?.addEventListener('keyboardWillHide', keyboardWillHideHandler); | ||
| }; | ||
|
|
||
| const destroy = () => { | ||
| win?.removeEventListener('keyboardWillShow', keyboardWillShowHandler!); | ||
| win?.removeEventListener('keyboardWillHide', keyboardWillHideHandler!); | ||
|
|
||
| keyboardWillShowHandler = keyboardWillHideHandler = undefined; | ||
| }; | ||
|
|
||
| const isKeyboardVisible = () => keyboardVisible; | ||
|
|
||
| init(); | ||
| return { init, destroy, isKeyboardVisible }; | ||
| }; | ||
|
|
||
| export type KeyboardController = { | ||
| init: () => void; | ||
| destroy: () => void; | ||
| isKeyboardVisible: () => boolean; | ||
| }; |
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 |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| import { createKeyboardController } from '../keyboard-controller'; | ||
|
|
||
| describe('Keyboard Controller', () => { | ||
| it('should update isKeyboardVisible', () => { | ||
| const keyboardCtrl = createKeyboardController(); | ||
|
|
||
| window.dispatchEvent(new Event('keyboardWillShow')); | ||
| expect(keyboardCtrl.isKeyboardVisible()).toBe(true); | ||
|
|
||
| window.dispatchEvent(new Event('keyboardWillHide')); | ||
| expect(keyboardCtrl.isKeyboardVisible()).toBe(false); | ||
| }); | ||
|
|
||
| it('should run the callback', () => { | ||
| const callbackMock = jest.fn(); | ||
| createKeyboardController(callbackMock); | ||
|
|
||
| window.dispatchEvent(new Event('keyboardWillShow')); | ||
| expect(callbackMock).toHaveBeenCalledWith(true); | ||
|
|
||
| window.dispatchEvent(new Event('keyboardWillHide')); | ||
| expect(callbackMock).toHaveBeenCalledWith(false); | ||
| }); | ||
| }); |
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.
Uh oh!
There was an error while loading. Please reload this page.