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

Rework !important hack to avoid flicker #600

Merged

Conversation

DennisTsar
Copy link
Collaborator

Before, the following was happening when an export Kobweb page was visited which used a conditional breakpoint style:

  1. The browser loaded the export HTML, which correctly included the !important styling
  2. When the JS was loaded, the styles were overridden by Silk initialization, which did not use !important
  3. On the next event loop, the Silk hack overwrote the styles to include !important

This meant that any styling that depended on the !important was broken between steps 2 and 3. This would manifest as a layout flicker.

The new approach bypasses Compose HTML styling altogether and instead registers these breakpoint styles directly to a stylesheet, effectively bypassing step 2.

Before, the following was happening when an export Kobweb page was visited which used a conditional breakpoint style:
1. The browser loaded the export HTML, which correctly included the `!important` styling
2. When the JS was loaded, the styles were overridden by Silk initialization, which did not use `!important`
3. On the next event loop, the Silk hack overwrote the styles to include `!important`

This meant that any styling that depended on the `!important` was broken between steps 2 and 3. This would manifest as a layout flicker.

The new approach bypasses Compose HTML styling altogether and instead registers these breakpoint styles directly to a stylesheet, effectively bypassing step 2.
@bitspittle bitspittle merged commit 45e4e52 into varabyte:0.19.1 Aug 30, 2024
1 check passed
@DennisTsar DennisTsar deleted the silk/breakpoint-display-important-fix branch September 18, 2024 21:03
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.

2 participants