-
Notifications
You must be signed in to change notification settings - Fork 167
[terra-form-select] Clicking to view dropdown causes window to scroll to the top while embedded in mpage #2682
Comments
We think we'll need a reduced test case to better debug this. |
@po016255 any updates on the reduced test case ? |
How do you want this reduced test case setup, this is currently a page accessible in powerchart. How are you guys going to be debugging this? The current example doesn't require manipulating any of the other controls on the page. |
Is this something you can recreate using gaia for your component? Ideally we will need something that we can look at that is outside of powerchart |
What do you need to load it in gaia? We have a dcos endpoint in solgm and deveng that can be used, it is the same url being loaded in powerchart. You can also run plan-js locally with mock data by checking it out, doing "npm install" and "npm run start". Working test url is http://localhost:8080/#/raw/tests/plan-js/plan-has-data You can choose any of the HCs and click modify to get to the page. Currently the issue is not happening in standalone IE11 directly. Does gaia recreate the iframe used in powerchart? |
@po016255 |
Is that https://github.cerner.com/MPagesEcosystem/mpage-gaia? We have a dcos endpoint that can be used, plan_engine for live data, and plan-js for mock data. They each have their own url. What project do you want to use? I can give you specific instructions based on what you want to use. It will result in creating a URL that you should be able to set for the iframe used by the mpages. |
I setup gaia to see what would be needed. It appears you just need a working tab in powerchart. Using the 6.13 static content you can use the live dev tab with: Signon is "oneplan" in deveng. I can send you the password. Within powerchart you can load by searching for patient "SCHREUR, GRACE" and choosing the tab called "One Plan". You can follow the instructions I had up top, click a health concern and then choose the modify button. The "Health Concern Status" box recreates the behavior in both chrome and ie. But you need to shrink the window so there is an outer scrollbar (unless your resolution is low enough to have the scroll bar be there already). |
Can you provide the code for the reproducible test-case mentioned above? Does this only happen when embedded in an iFrame? Does the page jump when using the arrow keys to navigation the dropdown list of options. Each time a new option becomes active (using keyboard up/down arrows) scrollIntoView is called. We want the list to smoothly scroll during keyboard arrow interactions when the dropdown list has an overflow. |
I tested arrow keys, it doesn't happen when you are just navigating up and down. It happens when you click the box to show the menu for the first time. Although, it will scroll back down to put the control in view when you hit enter to select something in the menu. Example:
|
I spent some time looking into this during office hours and I do think that scrollTop might provide a solution to resolve the iframe jumping. I was able to reproduce this locally by running the terra-core site in IE 10 using virtual box and adding an iframe into the document that referenced back to the select documentation page. <iframe src="/components/terra-form-select/form-select/select" /> Opening a select within the iframe and using the arrow keys to navigate the options caused the page to jump. If we proceed with scrollTop we'll need to make sure we calculate the scroll offsets appropriately for arrow key navigation when the dropdown opens above/below as well as when the dropdown has a custom max height and is scrollable. |
@StephenEsser, as @supreethmr mentioned above we were able to fix this issue in our dev-site when form-select is rendered inside the iframe. we are working with the ipoc team here in BLR to render the same version of form-select in powerchart to make sure it works fine there also before logging the PR. |
I was wrong about scrollIntoView() method being reason for scrolling page to top on form-select open. scrollIntoView() was called on keyboard navigation in above mentioned scenario. As @StephenEsser mentioned scrollIntoView() does jumps page when using keyboard for navigation in form-select but on form select open it is focus() method which is causing page to scroll. Root Cause : document.querySelector(this.selectMenu).focus(); I was able to re-produce this issue in chrome by modifying dev-site DefaultValueZero test example. Video of scroll issue in chrome Video of scroll issue in IE 11/10 I was able to fix this in all browser including IE11 by using But |
Okay, I think I have a better understanding of what is happening. Every focusable element within an iframe can shift the parent window. You can reproduce this by adding the form-input doc-site page into the iframe and using tab to navigate through the focusable items in the iframe. It will shift the parent window. Causing a similar jump effect. This is default behavior of the browser and I don't think it can be avoided. The terra-form-select example makes this jump look more extreme because it is using hookshot to portal the content. Hookshot, by default, positions content invisible in the top left hand corner of the screen. Because we're using a 10 millisecond timeout before calling focus, I believe that the hookshot content is actually still positioned into the top lefthand corner of the iframe when we call focus(). Causing the page to jump the maximum distance to the top. For testing purposing, increasing the timeout before calling focus can prevent the page from jumping. This allows the hookshot content to be property positioned on screen before focusing it. In general, I don't think we should be using timeouts at all. In this case, since we are already using them, we might look into seeing how much of a timeout it takes to fix this issue. But a better solution would be to call focus only after we know the dropdown has been enabled/positioned. setState takes a callback function. We should only focus the menu once we know it has been positioned. ( Conditionally focus it if necessary. ) Specifically the isEnabled prop which is passed to the Dropdown and onto Hookshot. |
Thanks @StephenEsser for routing me to actual root cause. I was able to test this by setting focus after dropdown is positioned, It does resolves page scroll issue and prevents page from jumping to top. I tested by replacing document.documentElement.scrollTop = activeOption.offsetTop; In keyboard navigation it fails to highlight the active option as we traverse through options using keyboard navigation keys could be due to setting scroll-top of document element to offsetTop of activeOption. |
with Further investigation on form-select I found that page jump within Iframe is due to hookshot. As @StephenEsser mentioned in his comment hookshot content would not be positioned by the time To ensure that page jump happens only when form-select rendered with hookshot, tested form-select with with without we can also recreate this issue in other components like terra-dropdown also. which uses hookshot to display menu-list. I also found reference of other select components like In below screenshot we can see that div with class name so would like to know your thoughts on using hookshot in form-select : @StephenEsser. |
Adding to my previous comment, I found out few caveats of using form-select with I tried to modify few styles in frame and dropdown styles to fix clipping issue. Since we have So I tried removing .is-touch-accessible {
display: inline-block;
left: auto;
margin-top: 2.31%; // (need to find the value for margin-top since drop-down position will be absolute)
position: absolute;
z-index: 9001; // use same z-index as hookshot
} well with above css changes, form-select with I have updated branch for reference. |
Long term we will need to investigate if it is possible to shift focus from a component into hookshot while using screen reader gestures on iOS mobile. If it is impossible we may need to investigate phasing hookshot out of the Select. This is a large and non-passive change that will need some planning. Short term we should focus on solutions that resolve the page jumping as much as possible. I'd recommend splitting this issue into multiple parts. The first part would be resolving the page jump on the initial focus using the setState callback solution above. The second part would be solving the issue for page jumping when using keyboard navigation. For the isTouchAccessible prop I think we should maintain the existing relative/absolute positioning logic. The clipping is always going to be limited by the nearest ancestor component with a relative style. Many of our components implement a relative positioning. We should encapsulate our positioning as much as possible. Solutions implementing the component will need to focus on designing around the component constraints. |
Bug Report
Description
While in an mpage, when you click the terra-form-select(default variant) to display the drop down contents, the page will scroll all the way up making it impossible to see the results. The popup is open and you can choose an option via keyboard(without being able to see it) or use scroll wheel to scroll down, but if you click the scrollbar the dropdown closes. This is behavior that will prevent consumers from performing this workflow.
Steps to Reproduce
The outermost mpage scroll bar will go from its current position all the way up. Depending on resolution, this bar could be all the way up already and thus this issue may not bee seen. But when using smaller resolutions, the user will see the drop down scroll out of view as in the gif. This most likely will happen normally in resolutions used on citrix by clients.
On a larger resolution monitor, you can reliably recreate the issue by shrinking down the size of the powerchart window.
Example on 4k monitor shrinking down the patient window slightly to recreate:
![terra-form-select_scroll_issue_4k](https://user-images.githubusercontent.com/12768193/66152489-2dc71400-e5df-11e9-9238-62544bd017a5.gif)
Additional Context / Screenshots
When the default variant is used, the page will scroll up. On the same health concerns modify view when the "expressed by" drop down is chosen, the page does not scroll. That drop down is using the "combo box" variant.
Teams discussion
Expected Behavior
Do not change the scroll position when clicking drop down or at least keep the drop down control in view if the scroll position reacts to opening the drop down.
Environment
@ Mentions
@StephenEsser
The text was updated successfully, but these errors were encountered: