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

[Legend] Actions icon misaligned when using Eui components #1832

Open
PhilippeOberti opened this issue Sep 30, 2022 · 1 comment
Open

[Legend] Actions icon misaligned when using Eui components #1832

PhilippeOberti opened this issue Sep 30, 2022 · 1 comment
Labels
bug Something isn't working :legend Legend related issue :styling Styling related issue

Comments

@PhilippeOberti
Copy link

PhilippeOberti commented Sep 30, 2022

Describe the issue
The icon shown when using the legendAction prop can be sometimes misaligned. Using for example eui components (like EuiToolTip, EuiButtonIcon...) breaks a bit the UI:

Image 2022-09-30 at 1 51 13 PM

Notice the misalignment of the legend action icon relative to the legend label

To Reproduce
See demo here which is based off of the 11_legend_actions.story and modify the getLegendAction method (found here). The Settings.legendAction prop expects ComponentType<LegendActionProps> which can be implemented with the EuiPopover. The EuiPopover expects a button prop to trigger the popover. The storybook example uses an html button tag like below...

// button as html button
const Button = (
  <button
    type="button"
    ref={ref}
    style={{
      display: 'flex',
      justifyContent: 'center',
      alignItems: 'center',
      paddingLeft: 2,
      paddingRight: 2,
    }}
    onClick={() => setPopoverOpen(!popoverOpen)}
  >
    <EuiIcon size="s" type="pencil" />
  </button>
);

However, when you instead use an EuiToolTip with EuiButtonIcon as the button, this causes the shift in the action alignment.

// button as EuiToolTip with EuiButtonIcon
const Button = (
  <EuiToolTip content="Test">
    <EuiButtonIcon
      aria-label="Test"
      iconType="boxesHorizontal"
      iconSize="s"
      size="xs"
      onClick={() => setPopoverOpen(!popoverOpen)}
    />
  </EuiToolTip>
);

This would result in something like this...

bad

Expected behaviour
Using EUI components shouldn't break the way the icons are displayed.

@PhilippeOberti PhilippeOberti added the bug Something isn't working label Sep 30, 2022
@PhilippeOberti
Copy link
Author

PhilippeOberti commented Sep 30, 2022

The main issue here is that we limit the hight of the legend action to 18px and the EuiButtonIcon height is controlled by the size prop.

It seems that there are a couple of ways to get around this issue:

First approach consists of applying some styles to the EuiButtonIcon, like

const Button = (
  <EuiToolTip content="Test">
    <EuiButtonIcon
      aria-label="Test"
      iconType="boxesHorizontal"
      iconSize="s"
      size="xs"
      onClick={() => setPopoverOpen(!popoverOpen)}
      // Add this style here 👇
      style={{ height: "100%" }}
    />
  </EuiToolTip>
);

Before

image

After

image


Another approach is to not use the EuiButtonIcon at all. This would avoid EUI highjacking the chart styles, and follow what's already done in the getLegendAction used in the story.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working :legend Legend related issue :styling Styling related issue
Projects
None yet
Development

No branches or pull requests

1 participant