polaris icon indicating copy to clipboard operation
polaris copied to clipboard

Popover with form components causes undesired scrolling

Open E-Mud opened this issue 8 years ago • 15 comments

Issue summary

Typing in an input inside a Popover causes the browser to scroll to the bottom of the page, and therefore forcing the popover to hide.

We were only able to reproduce this in Safari, but not only in our app but also in the Polaris examples page. Here you can see a video of the issue. Safari automatically scrolls to the input you are typing if it's "out of view" but in this case it seems that the Popover position is not correctly calculated.

Expected behavior

Typing in an input inside a Popover doesn't cause any scrolling. Open popover are never "out of view" so they shouldn't trigger any scroll.

Actual behavior

Browser scrolls to the bottom of the page when you type in an input inside a Popover, forcing the Popover to hide.

Steps to reproduce the problem

(As in the example video from above)

  1. Navigate to Popover examples page and open Popover with form components example
  2. Click on Filter button
  3. Click on text box next to Tags
  4. Type a

Specifications

  • Are you using the React components? (Y/N): Yes
  • Polaris version number: 2.1.2
  • Browser: Safari v11.1.1
  • Device: MacBook Pro
  • Operating System: OS X v10.13.5

EDIT: Added correct link to video

E-Mud avatar Jun 14 '18 10:06 E-Mud

If you can provide us with a workaround in the meantime it would very helpful. I already tried preventDefault in the keyup/keydown/keypress event coming from the input but it didn't work.

E-Mud avatar Jun 14 '18 10:06 E-Mud

@E-Mud Thanks for reporting this! Can you share the correct link to the video?

kaelig avatar Jun 14 '18 17:06 kaelig

@kaelig Oops!

Sorry I forgot to add the correct link: video

E-Mud avatar Jun 14 '18 17:06 E-Mud

Took a looksy 👀 .

I was able to replicate this in Safari on the Polaris documentation site: https://polaris.shopify.com/components/overlays/popover

However… I wasn't able to replicated it in the local Polaris dev Playground (also on Safari).

It works fine in Chrome and Firefox though 🤔 (both Polaris documentation + local Playground)

Hope this helps!


Device:

  • Mac OS 10.12.6

ItsJonQ avatar Jun 15 '18 20:06 ItsJonQ

A couple more things that might be helpful:

  • I couldn't reproduce it with fixed={true} on version 2.2.0
  • We built our own popover with the same basic functionality. The key difference is that ours doesn't have any animation for opening. Could the animation be the cause?

E-Mud avatar Jun 18 '18 06:06 E-Mud

I can reproduce with the latest release (2.3.0) both inside and outside of the Polaris site. I’ve opened an issue in our internal tracker and we’ll look into this as soon as possible.

ry5n avatar Jul 03 '18 19:07 ry5n

This may be related, or perhaps intentional, but the popover also disappears when there's not enough space in the window:

Disappearing Popover

The code to reproduce that is a simple Popover with a ColorPicker in it (See sandbox) You can also get it into a state where it seems like the Popover doesn't open at all if you make the window smaller.

This all sounded similar to this bug, but if it's different, I can open a different issue.

mbaumbach avatar Aug 19 '18 03:08 mbaumbach

@mbaumbach Thank for bringing that to our attention. We're looking into it.

solonaarmstrong-zz avatar Aug 23 '18 12:08 solonaarmstrong-zz

@ItsJonQ If there is not enough content to scroll the page, the issue doesn't present itself. Popover uses portal, which is positioned as a sibling element to the rest of the content and Safari scrolls to it if you type in a text input within the popover.

Add something like this below your popover in the playground and you'll see the issue.

{Array.from({length: 40}).map(() => (
  <p>Content so the page scrolls</p>
))}

solonaarmstrong-zz avatar Aug 23 '18 12:08 solonaarmstrong-zz

@mbaumbach I'm looking into a default behaviour for this that doesn't cause the bug. You can also use preferredPosition="above" for a popover that appears at the bottom of the page.

solonaarmstrong-zz avatar Aug 28 '18 01:08 solonaarmstrong-zz

@solonaarmstrong Thanks for looking into it. We have a somewhat tall popover in our production app with a ColorPicker in it, hex textfield, and recent color swatch (Screenshot below). We run into this issue regardless of the preferredPosition as some of our customers have some pretty small resolutions apparently! Probably could argue we find a way to make this smaller using a different design, but thought I'd share our real world example. 😀

Color picker popover

mbaumbach avatar Sep 12 '18 19:09 mbaumbach

Both of these bugs are no longer reproducible and may have been fixed with the latest Safari update. Closing and will reopen if it resurfaces.

solonaarmstrong-zz avatar Sep 19 '18 19:09 solonaarmstrong-zz

@solonaarmstrong The sandbox I posted in the above comment is still reproducible in Chrome, Safari, and Firefox for me. Perhaps that's a different issue though, so let me know if you'd like me to open a different issue for that!

mbaumbach avatar Sep 19 '18 22:09 mbaumbach

Hi @mbaumbach,

Please go ahead and open a separate issue, since the original issue with typing input and Safari has been fixed by a Safari update. Thanks!

dpersing avatar Sep 20 '18 15:09 dpersing

Thanks @dpersing, I've opened #435!

mbaumbach avatar Sep 24 '18 13:09 mbaumbach