Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 15 additions & 7 deletions core/src/components/searchbar/searchbar.ios.scss
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@

@include padding($searchbar-ios-padding-top, $searchbar-ios-padding-end, $searchbar-ios-padding-bottom, $searchbar-ios-padding-start);

height: $searchbar-ios-input-height + $searchbar-ios-padding-top + $searchbar-ios-padding-bottom;
min-height: $searchbar-ios-input-min-height + $searchbar-ios-padding-top + $searchbar-ios-padding-bottom;

contain: strict;
contain: content;
}

.searchbar-input-container {
height: $searchbar-ios-input-height;
min-height: $searchbar-ios-input-min-height;
}


Expand All @@ -45,16 +45,24 @@
// -----------------------------------------

.searchbar-input {
@include padding(0, 28px);
@include padding(6px, 0px);

height: 100%;

font-size: 17px;
font-size: dynamic-font(17px);
font-weight: 400;

contain: strict;
}

/**
* We should only account for the clear button
* if the clear button is actually visible. Otherwise
* long text in an input can get cut off when it does not need to.
*/
:host(.searchbar-has-value.searchbar-should-show-clear) .searchbar-input {
@include padding(null, dynamic-font(28px));
}

// Searchbar Clear Input Icon
// -----------------------------------------
Expand All @@ -65,7 +73,7 @@

position: absolute;

width: 30px;
width: dynamic-font(30px);
height: 100%;

border: 0;
Expand Down Expand Up @@ -101,7 +109,7 @@
}

:host(.searchbar-left-aligned) .searchbar-input {
@include padding-horizontal(30px, null);
@include padding-horizontal(dynamic-font(30px), null);
}


Expand Down
9 changes: 5 additions & 4 deletions core/src/components/searchbar/searchbar.ios.vars.scss
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ $searchbar-ios-padding-bottom: $searchbar-ios-padding-top !de
$searchbar-ios-padding-start: $searchbar-ios-padding-end !default;

/// @prop - Font size of the searchbar cancel button
// The cancel button on iOS does not scale with Dynamic Type
$searchbar-ios-cancel-button-font-size: 16px !default;

/// @prop - Color of the searchbar cancel button
Expand All @@ -25,13 +26,13 @@ $searchbar-ios-cancel-button-color: ion-color(primary, base) !defa
$searchbar-ios-cancel-button-background-color: transparent !default;

/// @prop - Size of the searchbar input search icon
$searchbar-ios-input-search-icon-size: 22px !default;
$searchbar-ios-input-search-icon-size: dynamic-font(22px) !default;

/// @prop - Color of the searchbar input search icon
$searchbar-ios-input-search-icon-color: $text-color-step-400 !default;

/// @prop - Height of the searchbar input
$searchbar-ios-input-height: 36px !default;
/// @prop - Minimum Height of the searchbar input
$searchbar-ios-input-min-height: 36px !default;

/// @prop - Border radius of the searchbar input
$searchbar-ios-input-border-radius: 10px !default;
Expand Down Expand Up @@ -61,4 +62,4 @@ $searchbar-ios-input-icon-opacity: .5 !default;
$searchbar-ios-input-clear-icon-color: $text-color-step-400 !default;

/// @prop - Size of the searchbar input clear icon
$searchbar-ios-input-clear-icon-size: 18px !default;
$searchbar-ios-input-clear-icon-size: dynamic-font(18px) !default;
8 changes: 4 additions & 4 deletions core/src/components/searchbar/searchbar.md.scss
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
.searchbar-search-icon {
@include position(11px, null, null, 16px);

width: $searchbar-md-input-search-icon-size + 1;
height: $searchbar-md-input-search-icon-size + 1;
width: $searchbar-md-input-search-icon-size;
height: $searchbar-md-input-search-icon-size;
}


Expand Down Expand Up @@ -59,12 +59,12 @@
// -----------------------------------------

.searchbar-input {
@include padding(6px, 55px);
@include padding(dynamic-font(6px), dynamic-font(55px));
@include background-position(start, 8px, center);

height: $searchbar-md-input-height;

font-size: 16px;
font-size: dynamic-font(16px);
font-weight: 400;

line-height: $searchbar-md-input-line-height;
Expand Down
4 changes: 2 additions & 2 deletions core/src/components/searchbar/searchbar.md.vars.scss
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ $searchbar-md-cancel-button-font-size: 1.6em !default;
$searchbar-md-input-search-icon-color: $text-color-step-400 !default;

/// @prop - Size of the searchbar input search icon
$searchbar-md-input-search-icon-size: 20px !default;
$searchbar-md-input-search-icon-size: dynamic-font(21px) !default;
Comment thread
averyrousseau marked this conversation as resolved.

@liamdebeasi liamdebeasi Aug 28, 2023

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an intentional change from 20px to 21px.

The actual width/height of the icon was 21px due to the following code:

width: $searchbar-md-input-search-icon-size + 1;
height: $searchbar-md-input-search-icon-size + 1;

I discussed with Brandy, and these variables were originally used for other things like background size which is why the 1px was not incorporated as part of the sass variable. However, the variable is only used for width/height so I made it part of the variable directly.


/// @prop - Height of the searchbar input
$searchbar-md-input-height: auto !default;
Expand All @@ -58,4 +58,4 @@ $searchbar-md-input-border-radius: 2px !default;
$searchbar-md-input-clear-icon-color: $text-color-step-400 !default;

/// @prop - Size of the searchbar input clear icon
$searchbar-md-input-clear-icon-size: 22px !default;
$searchbar-md-input-clear-icon-size: dynamic-font(22px) !default;
1 change: 1 addition & 0 deletions core/src/components/searchbar/searchbar.scss
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
display: block;

width: 100%;
min-height: inherit;

border: 0;

Expand Down
8 changes: 7 additions & 1 deletion core/src/components/searchbar/searchbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,13 @@ export class Searchbar implements ComponentInterface {
const inputLeft = 'calc(50% - ' + textWidth / 2 + 'px)';

// Calculate the icon margin
const iconLeft = 'calc(50% - ' + (textWidth / 2 + 30) + 'px)';
/**
* We take the icon width to account
* for any text scales applied to the icon
* such as Dynamic Type on iOS as well as 8px
* of padding.
*/
const iconLeft = 'calc(50% - ' + (textWidth / 2 + iconEl.clientWidth + 8) + 'px)';

// Set the input padding start and icon margin start
if (rtl) {
Expand Down
24 changes: 24 additions & 0 deletions core/src/components/searchbar/test/a11y/searchbar.e2e.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { expect } from '@playwright/test';
import { configs, test } from '@utils/test/playwright';

configs({ directions: ['ltr'] }).forEach(({ title, screenshot, config }) => {
test.describe(title('searchbar: font scaling'), () => {
test('should scale text on larger font sizes', async ({ page }) => {
await page.setContent(
`
<style>
html {
font-size: 36px;
}
</style>
<ion-searchbar value="My Text" show-cancel-button="always" show-clear-button="always"></ion-searchbar>
`,
config
);

const searchbar = page.locator('ion-searchbar');

await expect(searchbar).toHaveScreenshot(screenshot(`searchbar-scale`));
});
});
});
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 28 additions & 0 deletions core/src/components/searchbar/test/basic/searchbar.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,3 +170,31 @@ configs({ directions: ['ltr'] }).forEach(({ title, screenshot, config }) => {
});
});
});

configs({ modes: ['ios'], directions: ['ltr'] }).forEach(({ title, screenshot, config }) => {
test.describe(title('searchbar: ios clear button text cut off'), () => {
test('text should not be cut off when clear button is hidden', async ({ page }) => {
await page.setContent(
`
<ion-searchbar show-clear-button="focus" value="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce non metus vel velit sollicitudin suscipit quis sed lectus. "></ion-searchbar>
`,
config
);

const searchbar = page.locator('ion-searchbar');
await expect(searchbar).toHaveScreenshot(screenshot(`searchbar-text-clear-hidden`));
});

test('text should be cut off when clear button is visible', async ({ page }) => {
await page.setContent(
`
<ion-searchbar show-clear-button="always" value="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce non metus vel velit sollicitudin suscipit quis sed lectus. "></ion-searchbar>
`,
config
);

const searchbar = page.locator('ion-searchbar');
await expect(searchbar).toHaveScreenshot(screenshot(`searchbar-text-clear-visible`));
});
});
});
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.