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

Mobile fixed toolbar: prevent whitespace and toolbar being scrolled off-screen #18945

Merged
merged 1 commit into from
Dec 9, 2019

Conversation

frontdevde
Copy link
Contributor

Description

This is a followup PR to #18686 which added a fixed toolbar to mobile.

This PR updates the hack we're using to make this work on mobile Safari (see #18632 for more context). The updated hack has the advantage that it also prevents the toolbar from being scrolled off-screen when scrolling directly on the toolbar. It also prevents the whitespace that mobile Safari erroneously adds on scroll bounce when scrolling beyond the end of the document.

How has this been tested?

Tested in mobile Safari on a physical iPhone 11 with iOS 13.2.3 installed.

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • My code has proper inline documentation.
  • I've included developer documentation if appropriate.
  • I've updated all React Native files affected by any refactorings/renamings in this PR. .

@frontdevde frontdevde added the Mobile Web Viewport sizes for mobile and tablet devices label Dec 5, 2019
@frontdevde frontdevde self-assigned this Dec 5, 2019
@frontdevde
Copy link
Contributor Author

Pinging @jasmussen as promised 👋Would be cool if you could take this for a spin.

Copy link
Contributor

@jasmussen jasmussen left a comment

Choose a reason for hiding this comment

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

This seems another VAST improvement:

  • It bounces much less frequently. @ellatrix I think you'll be happy to see this too, I know you've fought this also.
  • It still bounces sometimes, but this is to be expected because of how Mobile Safari, and it's nice to see it less frequently.
  • So good to see the removal of setTimeout, that's almost always race-conditiony

new

Unrelated to this branch, the drag handle is now visible on mobile. I'm sure that happened elsewhere, and it makes this issue worse:

Screenshot 2019-12-06 at 08 34 07

It also doesn't work, neither when the toolbar is detached (are you dragging the toolbar?) nor techncially, it just flickers the screen. Not to be fixed here, just something to look at ticketing. Perhaps a new ticket with mobile improvements:

  • Show back button, hide adminbar
  • Hide drag handle
  • Look at detaching horizontally adjusting the popover in addition to the vertical centering that happens, so it doesn't get cropped

One question: does the new listener affect performance? Running in the simulator performance seemed unchanged and totally fine. But is there any way we can test this/verify? Connect the Safari debugger and profile, or something? Test a REEEEEEALLY long document and scroll to the bottom?

@@ -86,10 +86,10 @@ export function initializeEditor( id, postType, postId, settings, initialEdits )

const isIphone = window.navigator.userAgent.indexOf( 'iPhone' ) !== -1;
if ( isIphone ) {
document.addEventListener( 'focusin', function( ) {
setTimeout( () => {
window.addEventListener( 'scroll', function( event ) {
Copy link
Member

Choose a reason for hiding this comment

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

So the purpose of this is to prevent scrolling on the window? Has the overflow technique been tried? (I don't see it mentioned in the comment.)

Copy link
Contributor

Choose a reason for hiding this comment

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

The purpose is to compensate for the scrolling that Mobile Safari does due to a very hacky decision to scroll up the html element whenever the softkeyboard is showing. The hack is better described in #18686 where the first version of this was merged.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Assuming we're talking about the same technique, we did try the overflow technique while testing various approaches when we were working on #18686. Unfortunately, most common approaches did not get us closer to fixing the issues we were seeing in mobile Safari as described in the previous PR as well as the related issue tickets.

@frontdevde
Copy link
Contributor Author

One question: does the new listener affect performance?

The listener is only added when viewed on an iPhone. There the listener shouldn't be a performance issue as it doesn't actually fire when scrolling in the editor. From what I can observe testing on a physical device while inspecting it, it only fires when a) you focus in on a block and the browser tries to scroll that block into view and b) you've reached the top/bottom of the page and the scroll bounce happens.

Test a REEEEEEALLY long document and scroll to the bottom?

Just to be sure I just did exactly that. I copied the team page template 100x times in the editor and did a test run on the physical device. There is absolutely no difference in performance noticeable.

@jasmussen
Copy link
Contributor

:ovation:

@frontdevde
Copy link
Contributor Author

Unrelated to this branch, the drag handle is now visible on mobile.

I'm not sure this PR is the right place to discuss this, as it is unrelated to the changes proposed here. Your suggestion to add a different issue ticket makes sense to me. That said, I do see the drag handle on the physical device as well but it does work as expected. I can scroll in the toolbar and select the items I need. There are more items in the toolbar than fit the screen, probably due to the addition of the block mover controls on the left. So in that sense it does make sense to see the drag handle. That said, it might not be the behavior we want.

@jasmussen
Copy link
Contributor

To reaffirm my previous approval, I think it's a good time to merge this, and it does not preclude further improvements from happening. For a couple of reasons:

  • what’s shipping with 5.3 is really bad on iPhones, this is substantially better
  • what’s shipping in 5.3 is bad for the lowest common denominator, Mobile Safari, also dumbing it down for Android users
  • the hack is iPhone only, and works well in the “standards mode” browsers like those on Android, or in small viewports on desktop

Mostly, it’s the correct design to optimize for, whereas the other approach was fraught with compromise.

Ship it!

@frontdevde frontdevde merged commit 1e21c7b into master Dec 9, 2019
@frontdevde frontdevde deleted the update/fixed-mobile-toolbar branch December 9, 2019 11:50
@youknowriad youknowriad added this to the Gutenberg 7.1 milestone Dec 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Mobile Web Viewport sizes for mobile and tablet devices
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants