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

chore: disable ssr for showcase app #563

Merged
merged 11 commits into from
Jan 22, 2025
Merged

Conversation

peterpeterparker
Copy link
Member

@peterpeterparker peterpeterparker commented Jan 20, 2025

Motivation

Without disabling SSR we would not be able to build the showcase case app once the component InfiniteScroll is effectively used in the UI. This is because IntersectionObserver is not a known NodeJS property.

Notes

PR that uses the InfiniteScroll in the UI is #562.

Changes

@dskloetd
Copy link
Collaborator

FYI, e2e test is failing on CI.

@peterpeterparker peterpeterparker marked this pull request as draft January 20, 2025 16:27
@peterpeterparker
Copy link
Member Author

@dskloetd did not had time to turn it back to draft, still debugging. I start thinking there is actually an issue in the implementation which become unmasked, somehow, by this change but, as I said, still debugging. Turned it into a draft.

@peterpeterparker
Copy link
Member Author

Display issue - or rendering race condition - was indeed reproducible on main and improved in ##565.

peterpeterparker added a commit that referenced this pull request Jan 21, 2025
# Motivation

Tests in #563 were failing. After debugging, I figured out that the
potential display issue actually already existed on the main branch.
Specifically, since the segment buttons have no fixed width, depending
on the rendering, it's possible that on mount, the buttons are not yet
fully rendered—meaning they haven't occupied their full width
yet—resulting in the indicator position not being accurately calculated.
Similarly, the buttons might be rendered, but the font could take time
to load, causing the indicator position to be calculated with the
fallback font instead of the final one. Additionally, if the language is
changed at runtime, it might result in a change in the buttons' length.

Long story short, observing the size of the container and repositioning
the indicator when the size changes ensures that the indicator is always
correctly positioned.

# Changes

- Use a `ResizeObserver` to set the indicator position.
- Mock `ResizeObserver` globally for vitest

# Screenshots

Before on main:

<img width="1536" alt="Capture d’écran 2025-01-21 à 07 19 52"
src="https://github.com/user-attachments/assets/615979f4-fb10-45c1-a1c2-d841d3ea8795"
/>

After:

<img width="1536" alt="Capture d’écran 2025-01-21 à 07 19 37"
src="https://github.com/user-attachments/assets/745806a2-cf0b-497a-8924-0aa638c8aa0c"
/>

# Tests

Tests of #563 should pass.
@peterpeterparker peterpeterparker marked this pull request as ready for review January 21, 2025 11:49
Copy link
Contributor

@AntonioVentilii AntonioVentilii left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTMtks

@peterpeterparker peterpeterparker merged commit ecde5eb into main Jan 22, 2025
9 checks passed
@peterpeterparker peterpeterparker deleted the chore/disable-ssr branch January 22, 2025 07:29
peterpeterparker added a commit that referenced this pull request Jan 22, 2025
# Motivation

Given that the `InfiniteScroll` component will need some adjustments for
compatibility with Svelte v5, I thought it would be a good idea to first
add an end-to-end test to verify that the scroll works as expected.

# Notes

Requires #563 configuration to build the showcase app.

# Changes

- Add a `testId` to the component
- Provide some demo and test data within the infinite scroll component
page
- Write e2e tests that assert that data are loaded on scroll
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.

3 participants