Skip to content

Commit

Permalink
[EuiBasicTable] Fix row heights jumping when actions are disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
cee-chen committed Jan 19, 2023
1 parent 0a86e46 commit 6bd050f
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
15 changes: 15 additions & 0 deletions src/components/basic_table/basic_table.styles.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

import { css } from '@emotion/react';

// Unsets the extra height caused by tooltip wrappers around table action buttons
// Without this, the row height jumps whenever actions are disabled
export const euiBasicTableActionsToolTipWrapper = css`
line-height: 1;
`;
7 changes: 6 additions & 1 deletion src/components/basic_table/collapsed_item_actions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { EuiButtonIcon } from '../button';
import { EuiToolTip } from '../tool_tip';
import { EuiI18n } from '../i18n';
import { Action, CustomItemAction } from './action_types';
import { euiBasicTableActionsToolTipWrapper } from './basic_table.styles';
import { ItemIdResolved } from './table_types';

export interface CollapsedItemActionsProps<T> {
Expand Down Expand Up @@ -186,7 +187,11 @@ export class CollapsedItemActions<T> extends Component<
const withTooltip = !allDisabled && (
<EuiI18n token="euiCollapsedItemActions.allActions" default="All actions">
{(allActions: ReactNode) => (
<EuiToolTip content={allActions} delay="long">
<EuiToolTip
content={allActions}
delay="long"
anchorProps={{ css: euiBasicTableActionsToolTipWrapper }}
>
{popoverButton}
</EuiToolTip>
)}
Expand Down
7 changes: 6 additions & 1 deletion src/components/basic_table/default_item_action.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
} from '../button';
import { EuiToolTip } from '../tool_tip';
import { DefaultItemAction as Action } from './action_types';
import { euiBasicTableActionsToolTipWrapper } from './basic_table.styles';
import { useGeneratedHtmlId } from '../../services/accessibility';
import { EuiScreenReaderOnly } from '../accessibility';

Expand Down Expand Up @@ -102,7 +103,11 @@ export const DefaultItemAction = <T extends {}>({
}

return enabled && action.description ? (
<EuiToolTip content={action.description} delay="long">
<EuiToolTip
content={action.description}
delay="long"
anchorProps={{ css: euiBasicTableActionsToolTipWrapper }}
>
{button}
</EuiToolTip>
) : (
Expand Down

0 comments on commit 6bd050f

Please sign in to comment.