FormidableLabs / FormidableLabs/react-swipeable

`preventScrollOnSwipe` does not work while focused on input

Open
#335 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
2.1k
Forks
149
PR merge metrics
No merged PRs in 30d

Description

**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:
```js
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:
```js
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

Contributor guide

Open the contributing guide

Research direction

Start at the useSwipeable implementation and trace how preventScrollOnSwipe is applied while an input is focused. Reproduce the supplied case on iOS Safari 17.0, then verify that the page no longer scrolls during a focused-input swipe while the existing handler behavior remains intact.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, typescript
Domain
frontend, mobile-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.