-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Description
Issue summary
When the activator
of a Popover
(or PositonedOverlay
) contains an input
element, the Overlay always uses said element to calculate its position and width/height.
That behavior causes at least two issues:
When an activator contains an input
that is hidden, the Overlay will have no width.
When a TextInput
has an icon prefix, the Overlay will not expand to the TextInput
's full width. It will not account for the width of the icon. This is usually the desired behavior. However, that is not always the case. We have at least one instance where we'd like to stretch the Overlay to the TextInput
's full width.
We have a few ideas on how to address this issue and would like to discuss them:
-
Introduce a
preferInputActivator
prop to thePopover
(and hencePositonedOverlay
component). This prop would betrue
by default to not introduce a breaking change.When it's
true
, the behavior does not change. The Overlay will continue to search for aninput
, and if it finds one, use it. If the consumer sets the prop tofalse
, the Overlay will never search for aninput
and always use theactivator
to calculate its dimensions. -
Introduce a
getActivatorReferencePositionNode
(name to be determined) prop. That'd be a function that the consumer can pass to return the node that should act as the reference for the Overlay's dimension calculation.The
activator
node would be passed as an argument. The default implementation would be non-breaking. We'd still search for theinput
and use that if it exists. However, this would allow us to override the function to return theactivator
where we want to use that instead.
This approach would also allow users to customize the position calculation beyond using an input
or not.
Reduced test case
Case for overlay not being shown at all when non-visible input is inside activator: https://codesandbox.io/s/eloquent-edison-skb9f
Case for not expanding when TextInput
has icon: https://codesandbox.io/s/cocky-mendel-my3v8
Specifications
- Are you using the React components? (Y/N): Y
- Polaris version number: 4.13.`
- Browser: all
- Device: all
- Operating System: all