-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Move <Layer> to use React portals when available #4724
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
Move <Layer> to use React portals when available #4724
Conversation
|
It looks like there is some code in CalloutContent.base.tsx that is relying on virtual parentage for determining whether or not it should dismiss callouts when focus is lost. protected _dismissOnLostFocus(ev: Event) { } With these changes, we're no longer setting the virtual parent of the layer, so this is causing the a ContextualMenu to dismiss itself as soon a sub menu is opened. I think we'll either need to do something where we wrap the call to ReactDOM.createPortal in a with a ref, so that we can set the virtual parent of the layer to be an element that is a DOM child as well. Something like this: and then in componentDidMount(): |
802fa18 to
fd2866e
Compare
| * Used for notifying applicable Layers that a host is available/unavailable and to re-evaluate Layers that | ||
| * care about the specific host. | ||
| */ | ||
| public static notifyHostChanged(id: string) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thinking about this change, I'll move the methods back and just redirect to the new ones to not break compat
|
@betrue-final-final Definitely previously accepted one. "Left center" means to the left of the target. |
|
Yep, looking into the screener tests |
2c55fb0 to
448ffd5
Compare
47ca75e to
515ef2f
Compare
|
Interesting... fixed the callout, broke the contextual menu. The actual change is not that complicated, but other components seem to indirectly depend on the order of operations in the |
|
The odd thing about the contextualmenu break is now it doesn't appear at all. I'll be there's an error in the contextualmenu somewhere. |
|
Also they really shouldn't be this dependant on order. They should only care about when they get mounted. I'll pull this branch over the weekend and see if I can't debug. |
|
@joschect I've fixed the Callout, it shouldn't try to position when the target is not yet available. That looks better now. Context menu should also be fixed, a recent change I made didn't set the virtualparent for initial render, which breaks the context menu sub menus. K, fixed. If no target is given, I needed to position anyway. |
|
@cschleiden Looks great. Thanks for fixing it! This changes are pretty awesome and should simplify a bunch of code. @dzearing We might want to make sure that people know that this change is coming since there could be some subtle side effects. |
joschect
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did some spot checking in pickers, dropdown, and combobox to make sure the new portal didn't impact some of the event handling. Looks good!
|
Merged master and now there are problems with combo and dropdown SSR tests, will fix. |
|
Had to pin the |
|
@micahgodbolt @ThomasMichon can you take a look? |
| import { PortalLayerBase } from './PortalLayer.base'; | ||
| import { getStyles } from './Layer.styles'; | ||
|
|
||
| const portalSupport: boolean = !!createPortal; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very interesting... Just wondering out loud - would this cause problems for a consumer of OUFR 5.x using the ES2015 module imports?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, I think (and I might be wrong here), if a consumer is on React 15 and consumes the ES2015 exports (/lib-es2015/), this would be an invalid import due to the static nature of ES2015 modules... This would then break all usages of Fabric, for instance, if it was in the browser.
* Use Portals when available for Callout * Update shrinkwrap * Set virtual parent for initial render * Only wait for target when required * Update shrinkwrap * update * Prevent markdown-to-jsx from upgrading * Add patch file for example app base change * Update Layer.tsx
)" This reverts commit 0283f2a.
* master: (52 commits) Marqueeselection style update (microsoft#4803) Applying package updates. FocusZone: Add the ability to stop focus from propagating outside the FocusZone (microsoft#4823) Unknown persona coin (microsoft#4809) Applying package updates. BaseButton: Allow Alt + Down on menu buttons to open the menu (microsoft#4807) Applying package updates. Website: Scroll to top of page on navigation (microsoft#4810) Applying package updates. ActivityItem: fix getstyles (microsoft#4802) Mark Slider#ValuePosition enum as deprecated as it is unused. (microsoft#4799) Icon: ensure `styles` still works. (microsoft#4805) Popup: Added check for onBlur to prevent focus setting focus to be incorrectly disabled when closing a menu in Chrome (microsoft#4804) Update package.json Move <Layer> to use React portals when available (microsoft#4724) Fix breadcrumb rendering issue when overflow item is at last index (microsoft#4787) Fixes focus issue for contextual menus (microsoft#4744) Remove redundant selected items prop on BaseExtendedPicker (microsoft#4769) SearchBox: New prop for turning off icon animation (microsoft#4794) Add functions to ContextualMenuItem to open and close menus on command (microsoft#4741) ...
* Move <Layer> to use React portals when available (#4724) * Use Portals when available for Callout * Update shrinkwrap * Set virtual parent for initial render * Only wait for target when required * Update shrinkwrap * update * Prevent markdown-to-jsx from upgrading * Add patch file for example app base change * Update Layer.tsx * Add event blocking to maintain traditional behavior that can be disabled by new prop. * Remove old LayerBase implementation. * Add portal utility helper and use in Tooltip. * Revert incorrect typing. * Change files. * Update users-cschleid-portalLayers_2018-05-03-15-52.json * Update snapshots for merge. * Add utility unit tests. * List dependency info for CI builds. * Fix test break due to change in enzyme-adapter-react-16. * Add Layer event boundary unit tests. * Allow Tooltip to appear within portal when target is in same portal. * PR feedback. * Clarifying comments.

Updated.
This has a new dependency @dzearing. I need "enzyme-to-json" for the snapshots.