Skip to content

fix(docs-infra): align search result icon with text on mobile#68012

Open
funsaized wants to merge 1 commit intoangular:mainfrom
funsaized:fix/search-result-icon-alignment
Open

fix(docs-infra): align search result icon with text on mobile#68012
funsaized wants to merge 1 commit intoangular:mainfrom
funsaized:fix/search-result-icon-alignment

Conversation

@funsaized
Copy link
Copy Markdown

@funsaized funsaized commented Apr 3, 2026

Summary

Fixes the vertically misaligned icon in search result items on mobile viewports.

Closes #68005

Problem

On narrow (mobile) viewports, the search result icon was pushed to its own flex line when the title text was too long. This caused the icon to appear at the top of the item, visually disconnected from the title text.

The root cause: .docs-search-result__label uses display: flex with flex-wrap: wrap. When the title span's min-content width (longest unbreakable word) plus the icon exceeded the container width, the title wrapped to the next flex line — leaving the icon orphaned on the first line.

Fix

An HTML structure change in search-dialog.component.html and corresponding CSS update in search-dialog.component.scss:

The title text and package badge are wrapped in a new <span class="docs-search-result__label__text"> container, while the icon stays as a direct sibling. This gives two flex children in __label:

  1. Icon (flex-shrink: 0) — fixed-size, never squeezed or separated.
  2. Text wrapper (flex: 1; min-width: 0; display: flex; flex-wrap: wrap) — takes remaining space; title text and badge flow inside it.

Since __label no longer has flex-wrap: wrap, the icon and text wrapper are always on the same flex line. Long title text word-wraps internally (overflow-wrap: break-word + min-width: 0). When the package badge doesn't fit, it wraps to the next line within the text wrapper — staying indented past the icon rather than dropping underneath it.

@google-cla

This comment was marked as outdated.

@pullapprove pullapprove bot requested a review from atscott April 3, 2026 11:03
@angular-robot angular-robot bot added the area: docs-infra Angular.dev application and infrastructure label Apr 3, 2026
@ngbot ngbot bot added this to the Backlog milestone Apr 3, 2026
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 3, 2026

Deployed adev-preview for 8c5134f to: https://ng-dev-previews-fw--pr-angular-angular-68012-adev-prev-jeurun9f.web.app

Note: As new commits are pushed to this pull request, this link is updated after the preview is rebuilt.

@atscott atscott requested review from JeanMeche and removed request for atscott April 3, 2026 16:10
@SkyZeroZx
Copy link
Copy Markdown
Contributor

SkyZeroZx commented Apr 3, 2026

It seems the same behavior is still occurring on my phone (Poco F5 Pro)
and on test devices (Chrome devtools ) like the iPhone 12 Pro / Pixel 3 XL

image

Copy link
Copy Markdown
Contributor

@erkamyaman erkamyaman left a comment

Choose a reason for hiding this comment

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

I believe this issue can't be fixed with CSS alone. There should be an HTML structure change. The icon, title text, and package badge (when present) can be wrapped together in a single container element or some other way so they always stay on the same flex line, preventing the icon from being separated from the text on narrow viewports.

@funsaized
Copy link
Copy Markdown
Author

funsaized commented Apr 4, 2026

@erkamyaman Updated the approach after testing locally. The previous commit wrapped icon + title + badge in a single container, but that caused the package badge to wrap underneath the icon on narrow viewports — same visual problem, different element.

The fix now keeps the icon as a direct child of __label and wraps only the title text + package badge in a __text container. This way:

  • __label has no flex-wrap, so the icon and __text are always on the same flex line
  • __text uses flex: 1; min-width: 0; display: flex; flex-wrap: wrap — the title text shrinks and word-wraps internally, and when the badge wraps it stays indented past the icon
  • Icon keeps flex-shrink: 0 so it never gets squeezed

Tested locally on narrow viewports — icon stays aligned with the title, and the badge wraps within the text column as expected.

@aparzi
Copy link
Copy Markdown
Contributor

aparzi commented Apr 4, 2026

@funsaized I believe that you should use rebase for collapse in single commit

On narrow viewports, the search result icon was pushed to its own flex line when the title text was too long, causing vertical misalignment.

The fix wraps the title text and package badge in a single container that manages its own flex layout, preventing the icon from being separated from the text on narrow viewports.

Fixes angular#68005
@funsaized funsaized force-pushed the fix/search-result-icon-alignment branch from 1676665 to 8c5134f Compare April 4, 2026 19:26
@funsaized
Copy link
Copy Markdown
Author

@funsaized I believe that you should use rebase for collapse in single commit

Ah good call.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

adev: preview area: docs-infra Angular.dev application and infrastructure

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Misaligned icon and text in search results item

5 participants