Skip to content

Commit c053fd9

Browse files
liamdebeasibrandyscarneyIonitron
authored
fix(searchbar): cancel icon aligns with back button (#28478)
Issue number: resolves #28468 --------- <!-- Please do not submit updates to dependencies unless it fixes an issue. --> <!-- Please try to limit your pull request to one type (bugfix, feature, etc). Submit multiple pull requests if needed. --> ## What is the current behavior? <!-- Please describe the current behavior that you are modifying. --> The cancel button in the searchbar used to align with the back button, but that behavior gradually regressed between Ionic v4 and Ionic v7. ## What is the new behavior? <!-- Please describe the behavior or changes that are being added by this PR. --> - Adjusted the padding on the searchbar back button - Reduced the size of the searchbar back button. It was currently set to 25.6px whereas the `ion-back-button` icon was 24px. This caused the icons to never align even with 9px. (This should cause a few additional diffs) - Added a screenshot test | v4 | v5 | v6 | v7 | branch | | - | - | - | - | - | | ![Screenshot 2023-11-06 at 5 41 16 PM](https://github.com/ionic-team/ionic-framework/assets/2721089/fadad5ba-00dc-42f2-b0c8-1968f47e90c9) | ![image](https://github.com/ionic-team/ionic-framework/assets/2721089/798e30a8-5001-41eb-880d-bd3b0becd4cb) | ![image](https://github.com/ionic-team/ionic-framework/assets/2721089/5e2841f7-a58c-43dc-8338-d9a355785ce9) | ![image](https://github.com/ionic-team/ionic-framework/assets/2721089/20e590a9-5341-490f-8a3e-ca3666b899e1) | ![image](https://github.com/ionic-team/ionic-framework/assets/2721089/d2143089-d636-44ec-a87e-28ef27709ffe) | Note that in v4 the alignment was slightly off. It was fixed in v5, but then broke in v6 and remained unchanged in v7 (until now). ## Does this introduce a breaking change? - [ ] Yes - [x] No <!-- If this introduces a breaking change, please describe the impact and migration path for existing applications below. --> ## Other information <!-- Any other information that is important to this PR such as screenshots of how the component looks before and after the change. --> Dev build: `7.5.4-dev.11699310489.151b2717` --------- Co-authored-by: Brandy Carney <[email protected]> Co-authored-by: ionitron <[email protected]>
1 parent 9e1e55a commit c053fd9

21 files changed

+38
-2
lines changed

core/src/components/searchbar/searchbar.md.scss

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,13 @@
3434
// -----------------------------------------
3535

3636
.searchbar-cancel-button {
37-
@include position(0, null, null, 5px);
37+
/**
38+
* The left edge of the cancel button
39+
* should align with the left edge
40+
* of the back button if the searchbar
41+
* is used in a toolbar.
42+
*/
43+
@include position(0, null, null, 9px);
3844

3945
background-color: $searchbar-md-cancel-button-background-color;
4046

core/src/components/searchbar/searchbar.md.vars.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ $searchbar-md-cancel-button-color: $text-color-step-100 !default;
2525
$searchbar-md-cancel-button-background-color: transparent !default;
2626

2727
/// @prop - Font size of the searchbar cancel button
28-
$searchbar-md-cancel-button-font-size: 1.6em !default;
28+
$searchbar-md-cancel-button-font-size: 1.5em !default;
2929

3030
/// @prop - Color of the searchbar input search icon
3131
$searchbar-md-input-search-icon-color: $text-color-step-400 !default;
-169 Bytes
Loading
-10 Bytes
Loading
-11 Bytes
Loading
-171 Bytes
Loading
-11 Bytes
Loading
15 Bytes
Loading

core/src/components/searchbar/test/basic/searchbar.e2e.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,3 +198,33 @@ configs({ modes: ['ios'], directions: ['ltr'] }).forEach(({ title, screenshot, c
198198
});
199199
});
200200
});
201+
202+
configs({ modes: ['md'], directions: ['ltr'] }).forEach(({ title, screenshot, config }) => {
203+
test.describe(title('searchbar: cancel button alignment'), () => {
204+
test('should align with the back button when used in a toolbar', async ({ page }, testInfo) => {
205+
testInfo.annotations.push({
206+
type: 'issue',
207+
description: 'https://github.com/ionic-team/ionic-framework/issues/28468',
208+
});
209+
await page.setContent(
210+
`
211+
<ion-header>
212+
<ion-toolbar>
213+
<ion-buttons slot="start">
214+
<ion-back-button default-href="#"></ion-back-button>
215+
</ion-buttons>
216+
<ion-title>Test</ion-title>
217+
</ion-toolbar>
218+
<ion-toolbar>
219+
<ion-searchbar show-cancel-button="always"></ion-searchbar>
220+
</ion-toolbar>
221+
</ion-header>
222+
`,
223+
config
224+
);
225+
226+
const header = page.locator('ion-header');
227+
await expect(header).toHaveScreenshot(screenshot(`searchbar-back-button-align`));
228+
});
229+
});
230+
});
3.71 KB
Loading

0 commit comments

Comments
 (0)