Skip to content
New issue

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

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

Already on GitHub? # to your account

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

Open
vursen opened this issue Dec 23, 2024 · 3 comments
Labels
bug Something isn't working Impact: Low known issue Known issue that can't be easily fixed Severity: Minor vaadin-icon

Comments

@vursen
Copy link
Contributor

vursen commented Dec 23, 2024

Description

Finding from #8355

In Safari and Firefox, 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 18.1.1
  • Firefox 133.0.3
@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

@tomivirkki
Copy link
Member

polyfill is nowadays skipped for Safari because it successfully passes the supportsCQUnitsForPseudoElements check

Could supportsCQUnitsForPseudoElements be enhanced to detect the bug?

@vursen vursen changed the title [icon] Icon font size ignores dynamically added CSS padding in Safari [icon] Icon font size ignores dynamically added CSS padding in Safari and Firefox Jan 7, 2025
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working Impact: Low known issue Known issue that can't be easily fixed Severity: Minor vaadin-icon
Projects
None yet
Development

No branches or pull requests

3 participants