Skip to content
This repository has been archived by the owner on Mar 29, 2024. It is now read-only.

Toolbar position issue within a position: sticky container #141

Open
serafinomb opened this issue Oct 21, 2018 · 1 comment
Open

Toolbar position issue within a position: sticky container #141

serafinomb opened this issue Oct 21, 2018 · 1 comment

Comments

@serafinomb
Copy link

serafinomb commented Oct 21, 2018

Hello,
I am having an issue with the toolbar position when the Editor is rendered inside a position: sticky element.

Demo: https://codesandbox.io/s/kk6p74226o

Notice how, by changing any text style after scrolling down, the toolbar moves up (by what seems to be the scroll offset from the parent container). The position gets calculated correctly when the element is not "sticky-ed".

I've done some debugging and the issue seems to be the function getSelectionRect (/src/util/index.js), which calls the getBoundingClientRect function on the selection range.
I am not quite sure why the native getBoundingClientRect function returns the wrong top value but it might have something to do with the component re-render right after a style-change.

Wrapping the getSelectionRect function call inside a requestAnimationFrame solves the issue but I am not sure it's the correct way to fix it.
Demo: https://codesandbox.io/s/j7k68l7833 (see /src/medium-draft/components/toolbar.js:85)

I would like to get some feedback before creating a PR.

@serafinomb
Copy link
Author

Hello @brijeshb42,
have you had time to look into this? Is there anything I can do to make it easier for you to review/reproduce the issue?

Please, let me know.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant