cybersemics / em

A beautiful, minimalistic note-taking app for personal sensemaking.
Other
277 stars 102 forks source link

[iOS] Prevent autoscroll to focused editable #1628

Open raineorshine opened 2 years ago

raineorshine commented 2 years ago

Steps to Reproduce

- a
  - b
  - c
  - d
  - e
  - f
  - g
  - h
  1. Set cursor to null and scroll so that all thoughts are within the viewport.
  2. Tap on h and enter edit mode

Current Behavior

The window scrolls down so that the focused thought is in the middle of the screen. The top thoughts are now obscured.

https://user-images.githubusercontent.com/750276/212205968-d020bc5d-fe3d-49a8-89e7-a64773f10df0.MOV

Expected Behavior

Autoscroll should scroll the minimum amount necessary to bring the cursor thought into view.

To Do

References

raineorshine commented 1 year ago

iOS Safari supports focus({ preventScroll: true }) as of v15.5:

https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/focus#browser_compatibility

However this doesn't help when entering edit mode, which uses the default browser touch events. We cannot preventDefault when a user taps on a thought, since we need the browser to place the caret where the user taps.

raineorshine commented 1 year ago

Solution: https://stackoverflow.com/a/76731361/480608

raineorshine commented 3 months ago

Related: #1751

Not currently reproducible, but may recur after the current approach to cropping space around visible thoughts is changed.