Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix scrolling lines into view #514

Merged
merged 2 commits into from
Oct 15, 2024
Merged

Conversation

Skalakid
Copy link
Collaborator

@Skalakid Skalakid commented Oct 9, 2024

Details

THis PR fixies the problem with scrolling elements into view.It changes the logic to now scroll the whole line into view instead of just a child element

Related Issues

Expensify/App#50174

Manual Tests

  1. Add a height limit to the input inside the example app to make the component scrollable
  2. Clear the input
  3. Add newlines so the scroll bar appears on the side of the input
  4. Paste emoji
  5. Verify if the emoji is fully visible

Linked PRs

src/web/utils/cursorUtils.ts Outdated Show resolved Hide resolved
Copy link
Collaborator

@BartoszGrajdek BartoszGrajdek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!

// In case the caret is below the visible input area, scroll to the end of the node
if (caretRect.top + caretRect.height > targetRect.top + targetRect.height) {
targetElement.scrollTop = caretRect.top - targetRect.top + target.scrollTop - targetRect.height + caretRect.height + 4;
return;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this return?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we only want to change scrollTop. Executing the rest of the code below can cause scroll jumps

@Skalakid Skalakid merged commit 1170502 into main Oct 15, 2024
5 checks passed
@Skalakid Skalakid deleted the @Skalakid/fix-scrolling-line-into-view branch October 15, 2024 10:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants