Skip to content

fix(searchbar): fix search icon sometimes being offset incorrectly#31212

Merged
ShaneK merged 5 commits into
ionic-team:mainfrom
droc101:main
Jun 12, 2026
Merged

fix(searchbar): fix search icon sometimes being offset incorrectly#31212
ShaneK merged 5 commits into
ionic-team:mainfrom
droc101:main

Conversation

@droc101

@droc101 droc101 commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Issue number: resolves #30434


What is the current behavior?

The search icon in an ion-searchbar is sometimes positioned incorrectly.

What is the new behavior?

If the positionPlaceholder function in searchbar.tsx detects that iconEl.clientWidth is 0, it will use a ResizeObserver to wait until the element has a width > 0, then run positionPlaceholder again.

Does this introduce a breaking change?

  • Yes
  • No

droc101 added 2 commits June 10, 2026 12:14
change the positionPlaceholder in searchbar.tsx to check if iconEl.clientWidth is zero and retry up to ten times if it is, fixing the search icon being incorrectly positioned in some cases

closes ionic-team#30434
@droc101 droc101 requested a review from a team as a code owner June 11, 2026 18:17
@droc101 droc101 requested a review from brandyscarney June 11, 2026 18:17
@vercel

vercel Bot commented Jun 11, 2026

Copy link
Copy Markdown

@droc101 is attempting to deploy a commit to the Ionic Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions github-actions Bot added the package: core @ionic/core package label Jun 11, 2026

@ShaneK ShaneK left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hey! Awesome first try at this problem! I left some comments - some need action, others are just suggestions (nits). I've also started the tests, but I do think they might fail at the lint step for reasons I detailed below

Comment thread core/src/components/searchbar/searchbar.tsx Outdated
Comment thread core/src/components/searchbar/searchbar.tsx Outdated
Comment thread core/src/components/searchbar/searchbar.tsx Outdated
Comment thread core/src/components/searchbar/searchbar.tsx Outdated
change the fix for search icon positioning to use a ResizeObserver waiting until width is greater than zero instead of only checking over 10 frames, which could be problematic on slower devices or connections

@ShaneK ShaneK left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nice refactor! Just a small thing that's easy to overlook

Comment thread core/src/components/searchbar/searchbar.tsx Outdated
droc101 added 2 commits June 12, 2026 11:18
move the ResizeObserver variable for the search icon into the class scope, disconnect it in the disconnectedCallback, and disconnect any existing one before creating a new one

@ShaneK ShaneK left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good to me and I've verified it works against the user reproduction by using this dev build:

8.8.11-dev.11781283724.13318488

Awesome work!

@ShaneK ShaneK added this pull request to the merge queue Jun 12, 2026
Merged via the queue into ionic-team:main with commit 3394c30 Jun 12, 2026
63 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

package: core @ionic/core package

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: ion-searchbar style is broken inside of ion-modal.

2 participants