Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[icon] Icon font size ignores dynamically added CSS padding in Safari #8397

Open
vursen opened this issue Dec 23, 2024 · 2 comments
Open

[icon] Icon font size ignores dynamically added CSS padding in Safari #8397

vursen opened this issue Dec 23, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@vursen
Copy link
Contributor

vursen commented Dec 23, 2024

Description

Finding from #8355

In Safari, the icon's font size does not take into account CSS padding when it's added dynamically:

image

Expected outcome

The icon's font size should adjust to match the new size of the container content box.

Minimal reproducible example

<script type="module">
  import '@vaadin/icon';
  import '@vaadin/vaadin-lumo-styles/font-icons.js';

  setTimeout(() => {
    const icon = document.querySelector('vaadin-icon');
    icon.style.padding = '4px';
  });
</script>

<vaadin-icon font-family="lumo-icons" char="ea0e"></vaadin-icon>

Environment

Vaadin version(s): 24.6 and earlier
OS: Mac OS

Browsers

Safari

@vursen vursen changed the title [icon] Icon font size does not take into account dynamically added CSS padding in Safari [icon] Icon font size ignores dynamically added CSS padding in Safari Dec 23, 2024
@vursen vursen added the bug Something isn't working label Dec 23, 2024
@vursen
Copy link
Contributor Author

vursen commented Dec 23, 2024

The issue seems to be a Safari bug since it can be reproduced with a plain HTML:

<style>
  #icon {
    width: 100px;
    height: 100px;
    container-type: size;
    box-sizing: border-box;
  }

  #icon::before {
    content: 'H';
    display: block;
    font-size: 100cqh;
    line-height: 1;
  }
</style>

<div id="icon"></div>

<script>
  setTimeout(() => {
    const icon = document.querySelector('#icon');
    icon.style.padding = '25px';
  }, 100)
</script>

The icon component includes a built-in polyfill for calculating the icon font size in browsers that don't support cqh units, which was improved in #6419 to subtract CSS padding from the font size. However, this polyfill is nowadays skipped for Safari because it successfully passes the supportsCQUnitsForPseudoElements check. Maybe we should consider re-enabling the polyfill for Safari at least until this bug is fixed.

@vursen
Copy link
Contributor Author

vursen commented Dec 24, 2024

Submitted a bug report to WebKit: https://bugs.webkit.org/show_bug.cgi?id=285127

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant