Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

fix(item): stop ios lines from disappearing - #31800

Open
thetaPC wants to merge 49 commits into
FW-7047-device-scale-factorfrom
FW-7047
Open

thetaPC wants to merge 49 commits into
FW-7047-device-scale-factorfrom
FW-7047

Conversation

@thetaPC

@thetaPC thetaPC commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Issue number: resolves #30772


What is the current behavior?

On iOS, WebKit skips borders thinner than one CSS pixel at some positions on the page, so the 0.55px line between items disappears while scrolling.

What is the new behavior?

  • Adds a hairline mixin that draws a line as a filled box along a top or bottom edge instead of a border. Without a thickness, it is one screen pixel thick at 1x, 2x and 3x.
  • Adds a mediaQuery recipe key: values under mediaQuery.min.resolution set the same variable inside a media query. A value a custom theme sets replaces the base theme's media query values for that key, so it applies on every screen.
  • Test pages merge a custom theme with the same rule as apps, so a page that sets a custom value gets it on every screen too.
  • ion-divider draws its line with the mixin, and the ios theme sets it to one screen pixel at each density.
  • ion-item draws its full and inset lines with the mixin in every theme, as the line and inner-line parts. The item keeps the space the border took, so heights don't change. The ios theme sets them to one screen pixel at each density.
  • The ios accordion draws the line above a header item that follows an expanded accordion. It uses the shade of the header item's color when it has one.
  • Adds an item hairlines test page that reproduces the missing lines.

Does this introduce a breaking change?

  • Yes
  • No

In every theme:

  • --border-width and --inner-border-width no longer draw the lines between items. Use lines="none" to hide a line, or style it with ion-item::part(line) (full width) or ion-item::part(inner-line) (inset). --border-color still sets the line color.
  • Hiding a line through its part with display: none keeps the space below it. lines="none" removes both.

In the ios theme:

  • --border-color on an accordion's header item no longer changes the line above it.

Other information

Known gaps

  • If an app merges its own values into the ios tokens instead of using Ionic's theme config, the ios 2x and 3x thickness values still apply, so a custom thickness only shows on 1x screens.
  • Other components with 0.55px borders (header, footer, tab bar, alert, datetime, form controls, split pane) move to the mixin in their own migrations.

How to test

Lines draw one screen pixel thick, with none missing, in Safari on the iOS 17.5 and 26.2 simulators at every position the hairlines page reaches.

Lines look lighter than before in desktop browsers and in Chrome's device toolbar. Those drew the old 0.55px border two screen pixels thick, and the new line is one screen pixel, which is what iPhones always drew.

Check Before After What to look for
Missing lines Copy the hairlines page to core/src/components/item/test/hairlines/index.html on next and run npm start Hairlines Open in Safari on an iPhone or the iOS simulator. Tap Shift a few times. Before, some lines disappear. After, every line stays visible.
Item lines Lines Lines Full, inset and no lines match each label. Colored items draw a darker shade of their color.
Content over a line Basic Basic The PIN item's red line stops at "Must enter 7 digits".
Accordion Basic Basic A line separates Mini Golf from Dining, dark yellow in the colored groups. Expand Exercise: no line above it.

Recipe values under mediaQuery.min.resolution set the same variable inside a media query. A value a custom theme sets replaces the base theme's media query values for that key, so it applies on every screen.
The line is a filled box instead of a border, since WebKit skips borders thinner than one CSS pixel at some positions. The ios theme sets the thickness per screen density.
@thetaPC
thetaPC added this pull request to stack #31795 November 20, 2026 19:15
@vercel

vercel Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
ionic-framework Ready Ready Preview Dec 5, 2026 4:02am UTC

Request Review

# Conflicts:
#	core/src/components/chip/test/basic/chip.e2e.ts-snapshots/chip-descender-ios-ltr-Mobile-Chrome-linux.png
#	core/src/components/chip/test/basic/chip.e2e.ts-snapshots/chip-descender-ios-ltr-Mobile-Firefox-linux.png
#	core/src/components/chip/test/basic/chip.e2e.ts-snapshots/chip-descender-ios-ltr-Mobile-Safari-linux.png
@thetaPC
thetaPC removed this pull request from stack #31795 November 24, 2026 19:13
@thetaPC
thetaPC changed the base branch from FW-6848 to FW-7047-device-scale-factor November 24, 2026 19:18
…o FW-7047

# Conflicts:
#	core/src/components/popover/test/basic/popover.e2e.ts-snapshots/popover-basic-basic-popover-ionic-md-rtl-light-Mobile-Firefox-linux.png
#	core/src/components/popover/test/basic/popover.e2e.ts-snapshots/popover-basic-basic-popover-ionic-md-rtl-light-Mobile-Safari-linux.png
#	core/src/components/popover/test/basic/popover.e2e.ts-snapshots/popover-basic-basic-popover-md-rtl-Mobile-Chrome-linux.png
#	core/src/components/popover/test/basic/popover.e2e.ts-snapshots/popover-basic-basic-popover-md-rtl-Mobile-Firefox-linux.png
#	core/src/components/popover/test/basic/popover.e2e.ts-snapshots/popover-basic-basic-popover-md-rtl-Mobile-Safari-linux.png
#	core/src/components/popover/test/standalone/popover.e2e.ts-snapshots/popover-standalone-basic-popover-md-rtl-Mobile-Chrome-linux.png
#	core/src/components/popover/test/standalone/popover.e2e.ts-snapshots/popover-standalone-basic-popover-md-rtl-Mobile-Firefox-linux.png
#	core/src/components/popover/test/standalone/popover.e2e.ts-snapshots/popover-standalone-basic-popover-md-rtl-Mobile-Safari-linux.png

@brandyscarney brandyscarney 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.

I reproduced #30772 in Safari on the iPhone 17 simulator (iOS 27, 3x) with a tab bar and a sub-pixel offset. A 0.3334px border and the 0.55px border with overflow: visible both still drop lines. Only a 1px border or a filled element keeps them, and a 1px border isn't a hairline. So I agree with drawing the line as an element and keeping the line/inner-line API the same in every theme.

I checked the comments below in the same simulator against the ionic-modular and fw-7047 previews, measuring screenshot pixels. The first three are regressions, the rest are cleanup.

Comment thread BREAKING.md Outdated

The lines between items are drawn with an element instead of a border, so `--border-width` and `--inner-border-width` no longer show, hide or resize them, and `--border-style` no longer changes their style. `--border-color` still sets their color.

`--border-width` and `--inner-border-width` still draw a border on the item, so an app that set them to thicken a line now gets that border on top of the line. Remove those overrides and style the `line` or `inner-line` part instead.

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.

The advice to "style the line or inner-line part instead" won't work for the most common case of making the line thicker. The visible line is a gradient fill of a fixed thickness, so ion-item::part(line) { height: 4px; } still draws 1 screen pixel. I confirmed this in the simulator:

thicken-ios

Rows from top to bottom: default line, height: 4px, then height: 4px with background: currentColor.

Adding background: currentColor gives the expected 4px (12 screen pixels at 3x). Could the entry include a thickening example that sets background? Something like:

ion-item::part(line) {
  height: 2px;
  background: currentColor;
}

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.

Done in a37838d with your example. The item keeps space for the default thickness only (refer to the item.md.scss thread), so the entry also says a thicker line covers the bottom of the content.

--inner-border-width: 0;
.item-line,
.item-inner-line {
@include hairline(bottom, currentColor, $item-md-border-bottom-width);

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.

Since the line no longer takes up layout space, content at the bottom of the item sits on it. With <ion-input label="Email" helper-text="Enter your email" counter="true" maxlength="20"> in an ion-item, Safari on iOS 27 shows 3 clear screen pixels between the "y" descender and the line before this change, and 0 after, so the descender touches the line. ios goes from 5 to 4 and doesn't touch. The ionic theme also uses a 1px line, so it's probably affected too.

Before After
overlap-md-before overlap-md-after
overlap-md-before-zoom overlap-md-after-zoom

Could the item reserve the line's thickness at the bottom, for example with padding on .item-native/.item-inner equal to the line, so the height and spacing stay as before? That would also remove the "an item with a line is slightly shorter" note from BREAKING.md.

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.

Done in 3c0a98b. In every theme, the item keeps the line's thickness as bottom padding on .item-native (full) or .item-inner (inset), so heights and spacing match ionic-modular again, and the "slightly shorter" note is gone. I measured item, list and accordion heights in WebKit at 2x and 3x against the ionic-modular preview, and they match. The ios accordion keeps its top line's space as padding on the header, so its height doesn't change either. Hiding a line through its part with display: none now keeps that space, so BREAKING.md says to use lines to hide or show one (559d58e). 4df7fa8 updates the two test pages that hid lines that way.

}

// The last accordion's header has no lines (refer to core.scss), so it has no top line either
:host(.accordion-next:not(.accordion-last)) .accordion-next-line {

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.

.accordion-next-line is shown for every :host(.accordion-next:not(.accordion-last)), whatever is slotted into the header. With <button slot="header"> headers and the first accordion expanded, the before preview has no line between Content A and Header B. The after preview shows one. Before, the line came from the header ion-item's border, so non-item headers never had one.

Before After
accordion-ios-before accordion-ios-after

Could the line only be shown when the header is an ion-item? The header item is already looked up for the color observer in accordion.tsx, so a host class set at that point would work.

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.

Done in cebbd00. The accordion adds an accordion-has-header-item class when an ion-item is slotted as the header, and the line only shows with it. A new test checks that the button headers on the basic page have no line, and it fails without the fix.


// TODO(FW-6865): read only `--ion-color-${color}-bold-shade` once the
// old color token is gone, along with the same fallback in `generateColorClasses`
nextLineEl.style.color = `var(--ion-color-${color}-shade, var(--ion-color-${color}-bold-shade))`;

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.

ionColor(color, 'shade') from the theme utils already builds this fallback chain, so it could be used instead of the hand-written string.

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.

Done in fb94efb.

Comment thread core/src/utils/theme.ts Outdated
return dppx ? `${query}, (-webkit-${range}-device-pixel-ratio: ${dppx[1]})` : query;
};

const isObject = (value: unknown): value is Record<string, unknown> =>

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.

This is the same check as isPlainObject in breakpoints.ts. Could that one be exported and reused here instead of adding a second copy?

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.

Done in 47243d5.

Comment thread core/src/utils/theme.ts Outdated
* The recipe key that holds the values a component uses inside media queries.
* Its path builds the query: `min.resolution['2dppx']` becomes
* `(min-resolution: 2dppx)`. The values set the same variables as the
* component's own, so unlike a state, the key is left out of the variable names:

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.

Could this drop "unlike a state"? The sentence still explains the behavior without the comparison:

Suggested change
* component's own, so unlike a state, the key is left out of the variable names:
* component's own, so the key is left out of the variable names:

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.

Done in 95d1baf.


:host(.accordion-next) ::slotted(ion-item[slot="header"]) {
--border-width: #{$item-ios-border-bottom-width 0px $item-ios-border-bottom-width 0px};
// Drawn as a filled box instead of a border on the header item

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.

"Drawn as a filled box instead of a border" explains the code by what it replaced. Something like this says why it exists:

Suggested change
// Drawn as a filled box instead of a border on the header item
// Drawn as a filled box so it stays visible at sub-pixel positions in WebKit

The same applies to item/item.common.scss:293 and divider/divider.scss:41.

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.

Done in 95d1baf, in all three places.

// it does in the app (refer to `mergeTheme`).
if (customTheme) {
theme = deepMerge(theme, customTheme);
theme = themeUtils.mergeTheme(theme, customTheme);

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.

This was the only call to the deepMerge defined at line 197, which is scoped inside the IIFE, so nothing else can reach it now. Can that function be removed along with its TODO?

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.

Done in b6d88ff.

This branch was successfully deployed

1 active deployment
Preview — caa809d7 Deployed Dec 5, 2026 by vercel[bot]
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.

4 participants