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

Update scroll lock logic to lock everything but disabled targets #858

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

marinaaisa
Copy link
Member

Bug/issue #129588759, if applicable:

Summary

Update scroll lock logic to lock everything but disabled targets

Dependencies

NA

Testing

Steps:

  1. Open Safari iOS in Simulator or use any iOS device
  2. Go to any documentation page
  3. Open the navigator
  4. Assert that you can scroll tags in the navigator

Checklist

Make sure you check off the following items. If they cannot be completed, provide a reason.

  • Added tests
  • Ran npm test, and it succeeded
  • Updated documentation if necessary

@marinaaisa marinaaisa requested review from mportiz08 and hqhhuang June 12, 2024 18:03
@@ -73,23 +74,30 @@ function advancedUnlock(targetElement) {
document.removeEventListener('touchmove', preventDefault);
}

const isVerticalScroll = ({ scrollHeight, scrollWidth }) => scrollHeight > scrollWidth;

Copy link
Contributor

Choose a reason for hiding this comment

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

If I understood this correctly, I'm not sure if we can determine if an element allows vertical or horizontal scroll just by comparing its scroll height to its width. I think we should compare scrollHeight to clientHeight maybe?

Copy link
Contributor

Choose a reason for hiding this comment

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

Thinking out loud here: what you implemented here determines if a container is more "portrait" or "landscape", but that may not translate exactly to the direction of the scroll. For example, a longer code block in a narrow viewport would be considered "portrait" but we most likely need it to scroll horizontally

Copy link
Member Author

Choose a reason for hiding this comment

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

In the example you give, I don't think that would happen because in the case of a code block, the scrollWidth would be greater than the scrollHeight.

A narrow viewport wouldn't affect the scrollWidth since it's a measurement of the width of an element's content, including content not visible on the screen due to overflow. Source.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ops... I was reading from here 😅
But I think my point still stands... The shape of the container doesn't necessarily translate to the desired scroll direction

Comment on lines +99 to +100
} else if (Math.abs(clientY) > Math.abs(clientX)) {
// prevent event if user tries to perform vertical scroll in an horizontal scrolling element
Copy link
Contributor

@hqhhuang hqhhuang Jun 13, 2024

Choose a reason for hiding this comment

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

So smart :PP
Is this how WebKit determines what's a vertical scroll?

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't have idea about how WebKit really works but here I'm just comparing the absolute value of clientY (how much the user has moved to the Y axis since it started the movement) vs the absolute value of clientX(how much the user has moved to the X axis since it started the movement).

So if the user has moved more in the Y axis than to the X axis, it's a vertical scroll.

Copy link
Contributor

Choose a reason for hiding this comment

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

I understand what you are doing here, but there are examples when a gesture that moved more in the X axis than the Y axis be considered a vertical scroll on an iOS device.
But realizing now, it's probably not possible to imitate the iOS implementation exactly.
I don't have a better idea on a better heuristic to use to determine the scroll direction either...

@@ -106,7 +107,7 @@
</div>
</div>
<TagList
v-if="displaySuggestedTags"
v-show="displaySuggestedTags"
:id="SuggestedTagsId"
ref="suggestedTags"
:ariaLabel="$tc('filter.suggested-tags', suggestedTags.length)"
Copy link
Contributor

@hqhhuang hqhhuang Jun 14, 2024

Choose a reason for hiding this comment

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

Do you think it could solve our problem if we applied the SCROLL_LOCK_DISABLE_ATTR here, on the entire taglist component, instead of on individual tags within it?

And also conditionally apply the disable attribute onto the input element by checking if modelValue is overflowing? This way we don't disable the lock when FilterInput is not overflowing.

@marinaaisa marinaaisa force-pushed the r129588759/scroll-container branch from 07b81dc to 6924446 Compare June 17, 2024 17:48
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.

2 participants