Skip to content

Fix flag rendering inside table cells in Safari - #2866

Merged
ganyicz merged 1 commit into
mainfrom
filip/fix-flag-in-table-safari
Oct 27, 2026
Merged

ganyicz merged 1 commit into
mainfrom
filip/fix-flag-in-table-safari

Conversation

@ganyicz

@ganyicz ganyicz commented Oct 26, 2026

Copy link
Copy Markdown
Collaborator

The scenario

When a user puts <flux:flag> inside a <flux:table> cell, Safari shows a zoomed-in strip of the flag instead of the whole flag.

<flux:table.cell>
    <flux:flag country="nl" />
</flux:table.cell>

before

The problem

The flag's <img> uses size-full (height: 100%), and WebKit has a legacy rule for percentage heights on images inside table cells: it walks up the containing blocks, and if every one has height: auto until it reaches a <td>, it resolves the percentage against the larger of the cell's height and the image's intrinsic height (RenderReplaced.cpp, "Don't let table cells squeeze percent-height replaced elements", webkit#15359).

The flag wrapper gets its height from aspect-ratio, so its height is still auto and the check skips right past it to the cell. The flag SVGs only have a viewBox, so the image gets a height of 342px or 512px. The wrapper clips it with overflow: hidden and object-cover crops the middle of it, which is what shows up as the zoomed-in flag.

Outside a table there's no cell in the chain, so the percentage resolves against the wrapper as expected. Chrome and Firefox don't have this rule.

The solution

Position the image absolutely to fill the wrapper, which is already relative. Percentage heights of absolutely positioned elements resolve against their containing block's padding box, so WebKit's table cell rule doesn't apply.

  <img
      src="{{ $src }}"
      alt="{{ $alt }}"
      loading="lazy"
      decoding="async"
-     class="size-full object-cover"
+     class="absolute inset-0 size-full object-cover"
  >

The wrapper's size comes only from its width and aspect-ratio, so taking the image out of flow doesn't change it. All sizes, circle, the fallback globe and custom w-*/h-* classes render the same as before outside tables.

after

Fixes #2864

@ganyicz

ganyicz commented Oct 26, 2026

Copy link
Copy Markdown
Collaborator Author

No actionable findings in PR #2866.

The existing relative wrapper, explicit width, and aspect ratio safely constrain the absolutely positioned image while preserving layout.

Static review only; Safari behavior wasn’t independently tested.

@ganyicz
ganyicz merged commit e0feb8a into main Oct 27, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Flag component does not render correctly inside a table in Safari

1 participant