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

Sticky behavior breaks in editor with parent overflow: auto #368

Open
makhnatkin opened this issue Sep 16, 2024 · 1 comment · May be fixed by #369
Open

Sticky behavior breaks in editor with parent overflow: auto #368

makhnatkin opened this issue Sep 16, 2024 · 1 comment · May be fixed by #369
Assignees

Comments

@makhnatkin
Copy link
Collaborator

Problem Statement

When the editor is placed inside a parent container with overflow: auto, the condition at this line (refPageOffset <= stickyOffset) fails to trigger, causing the sticky header functionality to stop working as expected.

Possible Solutions

  1. Utilizing Intersection Observer API:
    We can explore using the Intersection Observer API to detect when elements enter or exit the viewport. This method would involve observing multiple elements, including those that might dynamically change. However, elements with position: sticky may not trigger the observer effectively due to their inherent visibility within the viewport.

  2. Direct Position Comparison:
    A simpler approach might involve directly comparing the initial top position of the ref component with the window scroll position or the scroll position of the nearest parent which has overflow: auto or window.

Key Considerations

  • Handling Dynamic DOM Changes: It's crucial to account for elements that might be added to the DOM at runtime, as these could disrupt the layout and the sticky behavior.
  • Flexible Offset Management: Introducing a CSS variable for the sticky offset allows for more fine-tuned control across different layouts and components, enhancing maintainability and adaptability in varied environments.
@makhnatkin makhnatkin self-assigned this Sep 16, 2024
@makhnatkin makhnatkin linked a pull request Sep 16, 2024 that will close this issue
@makhnatkin
Copy link
Collaborator Author

We should also check the behavior in the Popup

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 a pull request may close this issue.

1 participant