-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Popover2 migration
Adi Dahiya edited this page Feb 3, 2021
·
35 revisions
-
@blueprintjs/popover2depends on React 16.8+. This is a stricter requirement than@blueprintjs/core. - This package also depends on v2.x of the
@popperjs/coreandreact-popperlibraries, while the core package depends on v1.x. Note that this means you will have two versions of Popper.js installed and possibly bundled into your application at runtime.
- The
positionprop is nowplacement, to match the Popper.js options.- "placement" is similar to "position", with a direct mapping that involves changing some keywords if you are using the more advanced placement options.
-
@blueprintjs/corev3.38.0+ includes support for<Popover placement>and<Tooltip placement>, so you may choose to try out the new prop semantics without switching completely to Popover2 first.
- There is no more
.bp3-popover-wrapperwrapper element surrounding the target and overlay. This was a long-requested enhancement to the component DOM structure, as it makes styling the component and its children easier.- You may have to remove some redundant/excess styles which targeted the old DOM structure.
- With
usePortal={true}, just the target is rendered in place (overlay is rendered in a portal). - With
usePortal={false}, both the target and overlay are rendered out to the DOM as siblings.
- <span class="bp3-popover-wrapper">
- <span class="bp3-popover-target">
- <button type="button" class="bp3-button bp3-intent-primary">
- <span class="bp3-button-text">Popover target</span>
- </button>
- </span>
- <div class="bp3-overlay bp3-overlay-inline foo"></div>
- </span>
+ <span class="bp3-popover2-target">
+ <button type="button" class="bp3-button bp3-intent-primary">
+ <span class="bp3-button-text">Popover target</span>
+ </button>
+ </span>
+ <div class="bp3-overlay bp3-overlay-inline foo"></div>-
The removal of the wrapper element means that the
classNameprop now gets applied directly to the rendered target (before, it was applied to the wrapper element). This is equivalent to whattargetClassNamedid before, so that that redundant prop has been removed. -
There is an option to no longer render a
.bp3-popover-targetwrapper element surrounding the target as well. IfrenderTargetprop is supplied, its return value will be rendered out directly to the DOM without a wrapper.- When using the
renderTargetAPI, you must take care to render a component which propagates HTML props to its rendered children, since the render props supplied to you (includingclassName, event handlers, etc.) are necessary for the Popover2 to function. See the "Structure" section of the docs for more info. - Note: in this case it is the consumer's responsibility to disable a
<Tooltip2>target which is a direct child of a<Popover2>when the popover is open (<Popover>would handle this automatically for you, with its wrapper element behavior).
- When using the
- <span class="bp3-popover-target">
- <button type="button" class="bp3-button">
- <span class="bp3-button-text">Target</span>
- </button>
- </span>
+ <button type="button" class="bp3-button">
+ <span class="bp3-button-text">Target</span>
+ </button>- The old API of supplying two children to
<Popover>, where the first is the target and the second is the content, has been removed. Please switch to specifying content with thecontentprop. - The old API of supplying a target as the first child of
<Popover2>is still available. In this case, a.bp3-popover-targetwrapper element will be generated around the target child, so that Blueprint can attach event handlers to it. - For certain prop configurations (
openOnTargetFocus={true}and hover interaction kinds), atabIndexwas previously generated and applied to the clonedprops.childrenelement directly. Now, thattabIndexis applied to thebp3-popover2-targetwrapper element to increase the chance of this feature working in more situations.
- <span class="bp3-popover-target">
- <button type="button" class="bp3-button" tabIndex="0">
+ <span class="bp3-popover-target" tabIndex="0">
+ <button type="button" class="bp3-button">
<span class="bp3-button-text">Target</span>
</button>
</span>- The
boundaryprop has changed types to match popper.js' definition of what a "boundary" is. Existingboundaryconfigurations which actually specify a "root boundary" ("viewport" or "document") must now be specified usingrootBoundary:
- boundary="viewport"
+ rootBoundary="viewport"- The
portalClassNameprop behavior has changed to better match its intent. It now applies the class to the Portal container element rather than the Overlay rendered by Popover2 / Tooltip2. See #4511.
- FAQ
- 6.x Changelog
- 5.x Changelog
- 5.0 pre-release changelog
- 4.x Changelog
- v4.0 & v5.0 major version semantic swap
- v6.0 changes
- Spacing System Migration: 10px to 4px
- react-day-picker v8 migration
- HotkeysTarget & useHotkeys migration
- PanelStack2 migration
- Table 6.0 changes