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

preventScrollOnSwipe does not work while focused on input #335

Open
willashley23 opened this issue Oct 22, 2023 · 0 comments
Open

preventScrollOnSwipe does not work while focused on input #335

willashley23 opened this issue Oct 22, 2023 · 0 comments

Comments

@willashley23
Copy link

Describe the bug
When an input field is focused on ios Safari, preventScroll flag does not work as intended, IE, the page still scrolls.

Steps or Sandbox to reproduce
This has to be reproduced inside an ios simulator like xCode or on your mobile device directly

  • Wrap a div with scroll handlers:
const handlers = useSwipeable({
    onSwiping: ({ deltaY }) => {
      if (deltaY > 100) {
        document.getElementById('AddModal').close();
      }
    },
    delta: { left: 100, right: 100, down: 100 },
    preventScrollOnSwipe: true,
  });
  • Place an input inside of this container
  • Place a ref on this input
  • when the component mounts, focus the input:
  useEffect(() => {
    inputRef.current.focus();
  }, []);

-While focused on the input, attempt to scroll down

  • observe the bug: the page will scroll when it shouldnt. You can verify this by removing focus from the input and then attempting to swipe again, and it will trigger the handler and prevent scrolling

Expected behavior
It should prevent scrolling behavior if I swipe while focused on an input

** Device/Browser **
Safari iOS 17.0

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

No branches or pull requests

1 participant