fix(searchbar): fix search icon sometimes being offset incorrectly#31212
Merged
Conversation
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 is attempting to deploy a commit to the Ionic Team on Vercel. A member of the Team first needs to authorize it. |
ShaneK
requested changes
Jun 11, 2026
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
requested changes
Jun 11, 2026
ShaneK
left a comment
Member
There was a problem hiding this comment.
Nice refactor! Just a small thing that's easy to overlook
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
approved these changes
Jun 12, 2026
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
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
positionPlaceholderfunction insearchbar.tsxdetects thaticonEl.clientWidthis 0, it will use aResizeObserverto wait until the element has a width > 0, then runpositionPlaceholderagain.Does this introduce a breaking change?