Sticky behavior breaks in editor with parent overflow: auto

Aperta
#368 1 commento 0 reazioni 1 assegnatario Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@makhnatkin ci sta già lavorando.

Dal 16/9/2024.

  • #369 di @makhnatkin — aperta

Valutazione

Questa issue non è ancora stata valutata.

Descrizione

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.
Lingua principale
TypeScript
Stelle
428
Fork
48
Merge medio
5g 15h
PR unite (30g)
47

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di gravity-ui/markdown-editor

Tutte le issue di gravity-ui/markdown-editor

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.