Sticky behavior breaks in editor with parent overflow: auto

Abierto
#368 1 comentario 0 reacciones 1 asignado Ver en GitHub

Los mantenedores suelen responder en 1 día

@makhnatkin ya está trabajando en esto.

Desde el 16/9/2024.

  • #369 de @makhnatkin — abierto

Evaluación

Este issue todavía no se ha evaluado.

Descripción

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.
Lenguaje dominante
TypeScript
Estrellas
428
Forks
48
Merge medio
5 d 15 h
PR fusionados (30 d)
47

Preparar el entorno

Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de gravity-ui/markdown-editor

Todos los issues de gravity-ui/markdown-editor

Issues similares

Más issues de TypeScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.