-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Improve how modals behave on iPhone #4082
Comments
CC: @youknowriad because I know you worked on modals. |
Two quick ideas for addressing "improvement number 2":
Worth exploring those if they are quick fixes. |
I started looking at improvement number 1. I thought an initial, quick solution would be to have
I haven't had a chance to look at whether there is existing editor state that will answer whether any popover is open but plan to resume on Monday. |
Nice @brandonpayton. I don't think we need all popovers to apply I think @youknowriad added a property to popovers, to make them modal on mobile. Like applied ot the inserter. Could we chain it so when a popover asks to be modal? |
Thanks, @jasmussen! I knew about Popover's |
I have a thought on how scroll lock should be coordinated between modal Popovers and other overlays (e.g., the publish options) and will work on a PR in the morning. |
Though perhaps this is not yet perfect, enough enhancements have been merged that it's decent, and any subsequent issues can be opened as new issues. |
The PR in #4081 improves the mobile situation on iPhone quite a bit. However there are still some issues remaining, notably around how modals behave.
Specifically, 4081 changes how scrolling behaves. Previously, we'd prevent scrolling on
body
, and instead enable scrolling on a specific element usingoverflow: auto;
. This is good, as it prevents scroll-bleed in things like the inserter. But on iOS, if you do that, then you still have "overscroll bounce", which means if you pull on the admin bar, you scroll that and thebody
element, causing a super janky scrolling experience for the one element you actually want to scroll. There's no clean fix for this, other than just accepting mobile safari for its quirks, and letting thebody
scroll.But this change affects how modals work, as it re-enables scroll bleed. Which brings us to improvement number 1 that should be made:
When a modal is showing, we should add a CSS class to
body
orhtml
, so that we can prevent scrolling of that when the modal is showing. Something like:The 2nd issue is that Mobile Safari has some rather unique behaviors when any inputfield receives focus. Notably it does two things — it scrolls the page so as to show the textfield, and it zooms it if the text is < 16px font-size, so it's more legible. 4081 fixes the zoom issue, but the scrolling is still pretty janky:
This brings us to improvement number 2 we need to make. It's difficult to figure out how to best fix this, but it seems as though the primary issue is that the modal itself is 100% tall, and so it seems like the zoom action vertically centers the modal, which of course means that when the text field is at the top of that, it's out of view.
A best guess as to what might fix this, would be the following pseudo code:
☝️ — it is my guess that by using
absolute
instead offixed
, combined with a 100% height (instead of stretching usingtop: 0; bottom: 0;
), we can make sure that the modal is not vertically centered when the soft keyboard is showing, but rather top-aligned, so the soft keyboard will simply cover the bottom stuff.A good way to test this if you are on a Mac and don't have an actual iPhone you can connect and debug, is to download Xcode. In Xcode you can select Xcode > Open Developer Tool > Simulator. If you then have Gutenberg running on your localhost, change the WordPress address to use
127.0.0.1
instead oflocalhost
. Then simply copy/paste the URL (something likehttp://127.0.0.1/wp-admin/post-new.php
) into Safari on the iPhone Simulator, and the Mac will take care of the bridging.The text was updated successfully, but these errors were encountered: