fix: prevent scroll jump when clicking on cell output#3159
fix: prevent scroll jump when clicking on cell output#3159dl-alexandre wants to merge 4 commits into
Conversation
There was a problem hiding this comment.
This should be removed most likely
4ce588e to
63a68aa
Compare
| refute render_component(FileSelectComponent, attrs(file: file)) =~ ".." | ||
| end | ||
|
|
||
| test "shows loading when changing directories" do |
| send_event(socket.assigns.target, {:set_file, file, %{exists: true}}) | ||
|
|
||
| {:noreply, assign(socket, loading: true)} | ||
| {:noreply, socket} |
|
Hi @josevalim and @aleDsz, Thank you both for the reviews! I've cleaned up the PR: Changes made:
Current PR #3159 scope:
The scroll jump fix is now isolated and ready for review. Thanks for catching the file mix-up! Let me know if you need any other adjustments. |
|
@dl-alexandre Could you rebase your PR with the main branch? Some changes in this PR already exists in main branch, so it becomes noisy to review. |
7a6a0e3 to
d5a71c8
Compare
|
@@aleDsz Done! Rebased and cleaned up. Changes:
Files changed:
The PR is now clean and focused only on the scroll jump fix. Ready for review! |
|
Which browser are you able to reproduce this in? From what I tried it works as expected in Chrome in Safari, but jumps in Firefox. Is what what you are seeing?
Hmm, when we remove |
d5a71c8 to
b22c221
Compare
|
@jonatanklosko Thanks for the detailed questions. Browser behavior: Regarding tabindex: Why CSS only: Would you like me to add a comment in the CSS explaining the rationale, or adjust the margin values? |
Moves loading state management from event handlers into update_file_infos/2 to ensure loading indicator only appears when actually fetching directory listings, not when running_files changes (e.g., notebooks start/stop). - Remove upfront loading assignments in set_file_system and set_path - Set loading only when dir != current_dir in update_file_infos - Add tests for loading behavior with directory vs running_files changes Fixes livebook-dev#3111
Add scroll-margin CSS to data-el-cell-body to reduce scroll jumps when the cell body receives focus (e.g., when clicking on cell output). Add mousedown handler in cell.js to preserve scroll position when clicking on non-editor areas of the cell body.
b22c221 to
6a405b2
Compare
|
I can still reproduce it in Firefox with these changes. As said, we should determine the underlying cause, especially that it is Firefox-specific. If you do, feel free to comment on the issue. |
Fixes #2951
Problem
When clicking on cell output (e.g., to copy text, expand a table cell), the page would unexpectedly scroll/jump. This happens because clicking on the cell output causes the cell body (with tabindex="0") to receive focus, triggering browser scroll behavior.
Solution
CSS fix: Added and to to reduce scroll jumps when the element receives focus.
JavaScript fix: Added mousedown handler in cell.js that:
Testing