Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Components: Introduce portal-based slot / fill alternative, render Popover as slot / fill #2966
This pull request seeks to refactor Popover to simplify rendering as a slot / fill pair, rather than require a custom context provider providing a DOM node render target.
Originally I sought to implement this using
Recognizing that React 16's portals feature provides the tools for a Slot / Fill implementation, I sought to explore what would be necessary for a first-party implementation. Happily it seemed to work quite well, needing only a context provider to register, unregister, and retrieve
We should decide whether this is worth using as a substitute to
Verify that there are no regressions in Popover usage, particularly:
@@ Coverage Diff @@ ## master #2966 +/- ## ========================================= - Coverage 33.15% 32.9% -0.25% ========================================= Files 200 202 +2 Lines 5836 5883 +47 Branches 1031 1040 +9 ========================================= + Hits 1935 1936 +1 - Misses 3293 3330 +37 - Partials 608 617 +9
referenced this pull request
Oct 11, 2017
Rebased to resolve conflicts. I started toying locally to see whether the custom implementation would work well for our other use of Slot / Fill and for the most part it does. One issue was if a fill is rendered before the slot is mounted. The updated implementation now tracks all fills and forces a re-render should a slot become registered for that name. Further, I made the provider context optional for slot and fills, avoiding the need to mock tests on Fill (default behavior will render children verbatim in-place).
Finally, since I did the work... I decided to just finish dropping
Hmm, this appears to be problematic, since for something like block inspector, if the sidebar panel isn't opened, the inspector controls will render adjacent the preview, rather than not render at all. Probably need to revert this specific change.
This grew a bit larger than I would have liked, but it should be pretty well settled now. In recent changes: