Skip to content
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

Fix/dataviews tooltip overlap #57026

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/components/src/button/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ export function UnforwardedButton(
variant,
__experimentalIsFocusable: isFocusable,
describedBy,
tooltipPortal,
tooltipPortalElement,
...buttonOrAnchorProps
} = useDeprecatedProps( props );

Expand Down Expand Up @@ -280,6 +282,8 @@ export function UnforwardedButton(
}
shortcut={ shortcut }
placement={ computedPlacement }
portal={ tooltipPortal }
portalElement={ tooltipPortalElement }
>
{ element }
</Tooltip>
Expand Down
6 changes: 6 additions & 0 deletions packages/components/src/button/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,12 @@ type BaseButtonProps = {
* Whether this is focusable.
*/
__experimentalIsFocusable?: boolean;

tooltipPortal?: boolean;
tooltipPortalElement?:
| HTMLElement
| ( ( element: HTMLElement ) => HTMLElement | null )
| null;
};

type _ButtonProps = {
Expand Down
8 changes: 7 additions & 1 deletion packages/components/src/tooltip/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,13 @@ function Tooltip( props: TooltipProps ) {
delay = TOOLTIP_DELAY,
hideOnClick = true,
placement,
position,
shortcut,
text,
portal = true,
portalElement,

// Deprecated props
position,
} = props;

const baseId = useInstanceId( Tooltip, 'tooltip' );
Expand Down Expand Up @@ -86,6 +90,8 @@ function Tooltip( props: TooltipProps ) {
id={ describedById }
overflowPadding={ 0.5 }
store={ tooltipStore }
portal={ portal }
portalElement={ portalElement }
>
{ text }
{ shortcut && (
Expand Down
5 changes: 5 additions & 0 deletions packages/components/src/tooltip/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,9 @@ export type TooltipProps = {
* The text shown in the tooltip when anchor element is focused or hovered.
*/
text?: string;
portal?: boolean;
portalElement?:
| HTMLElement
| ( ( element: HTMLElement ) => HTMLElement | null )
| null;
};
3 changes: 3 additions & 0 deletions packages/dataviews/src/item-actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ function ButtonTrigger( { action, onClick } ) {
isDestructive={ action.isDestructive }
size="compact"
onClick={ onClick }
tooltipPortal={ false }
/>
);
}
Expand Down Expand Up @@ -168,6 +169,7 @@ export default function ItemActions( { item, actions, isCompact } ) {
size="compact"
icon={ moreVertical }
label={ __( 'Actions' ) }
tooltipPortal={ false }
/>
}
placement="bottom-end"
Expand All @@ -190,6 +192,7 @@ function CompactItemActions( { item, primaryActions, secondaryActions } ) {
size="compact"
icon={ moreVertical }
label={ __( 'Actions' ) }
tooltipPortal={ false }
/>
}
placement="bottom-end"
Expand Down
6 changes: 4 additions & 2 deletions packages/dataviews/src/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,14 @@
}
}
thead {
position: sticky;
top: -1px;
z-index: z-index(".components-tooltip") + 1;

tr {
border: 0;
}
th {
position: sticky;
top: -1px;
background-color: lighten($gray-100, 4%);
box-shadow: inset 0 -#{$border-width} 0 $gray-100;
border-top: 1px solid $gray-100;
Expand Down
Loading