Skip to content

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

@makhnatkin

Description

@makhnatkin

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.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions