Skip to content

feat(legend): add legendActionOnHover option to show actions on hover#2773

Merged
maryam-saeidi merged 22 commits intoelastic:mainfrom
maryam-saeidi:2444-filter-on-hover
Feb 12, 2026
Merged

feat(legend): add legendActionOnHover option to show actions on hover#2773
maryam-saeidi merged 22 commits intoelastic:mainfrom
maryam-saeidi:2444-filter-on-hover

Conversation

@maryam-saeidi
Copy link
Copy Markdown
Member

@maryam-saeidi maryam-saeidi commented Jan 20, 2026

Summary

The legendActionOnHover prop is now available in the Settings component to control when legend action icons are displayed. When set to true, legend actions (like filter buttons) are hidden by default and only appear when hovering over a legend item, providing a cleaner and less cluttered legend appearance. The action remains visible while interacting with it and supports full keyboard accessibility.

Screen.Recording.2026-01-29.at.17.06.14.mov

Example usage

      <Chart>
        <Settings
          showLegend
          legendActionOnHover // <-- new prop
          legendPosition={Position.Bottom}
          legendAction={LegendAction}
        />
        <Axis id="bottom" position={Position.Bottom} />
        <Axis id="left" position={Position.Left} />
        <BarSeries
          id="bars"
          xScaleType={ScaleType.Ordinal}
          yScaleType={ScaleType.Linear}
          xAccessor={0}
          yAccessors={[1]}
          data={[
            ["A", 10],
            ["B", 20],
            ["C", 15],
          ]}
        />
      </Chart>

Details

  • Added legendActionOnHover boolean prop to Settings (default: false)
  • Created useActionFocusManagement hook to manage focus state for legend actions
  • Added CSS classes echLegendItem--actionOnHover and echLegendItem--isActive to control visibility
  • Action visibility is triggered by :hover, :focus-within, or active state (when clicked)
  • Handles edge case where modals/popovers restore focus to their trigger after closing
  • Works with both regular and tabular legend layouts
Scenario Screenshot
Regular action image
Tabular action image
Keeping selected action visible image

Issues

Closes #2444

Checklist

  • The proper feature labels have been added (e.g. :interactions, :axis)
  • All related issues have been linked (i.e. closes #123, fixes #123)
  • Unit tests have been added or updated to match the most common scenarios
  • The proper documentation and/or storybook story has been added or updated
  • The code has been checked for cross-browser compatibility (Chrome, Firefox, Safari, Edge)

🤖 This pull request was assisted by Cursor

@maryam-saeidi maryam-saeidi self-assigned this Jan 20, 2026
@maryam-saeidi maryam-saeidi added the :legend Legend related issue label Jan 20, 2026
@maryam-saeidi
Copy link
Copy Markdown
Member Author

@markov00 In the current implementation, when moving between cells with keyboard, the action remains visible afterwards as seen below (when clicked, only that action will be visible):

Screen.Recording.2026-01-21.at.14.53.14.mov

I tried briefly to see if I can make keyboard experience similar to click with mouse, but there are so many edge cases and I didn't find a straightforward way to do so. I think the current implementation is good enough for the keyboard scenario, wdyt?

@maryam-saeidi
Copy link
Copy Markdown
Member Author

buildkite update vrt

@maryam-saeidi maryam-saeidi changed the title feat(legend): Add onHover state for actions fix(legend): Add onHover state for actions Jan 22, 2026
@delanni
Copy link
Copy Markdown
Member

delanni commented Jan 23, 2026

buildkite build this

@delanni
Copy link
Copy Markdown
Member

delanni commented Jan 23, 2026

We're in the process of migrating the build pipeline of this repo to an elastic-wide from the custom one we had before, this PR might require an admin-merge when deemed ready because some checks seem to be stuck.

@maryam-saeidi maryam-saeidi changed the title fix(legend): Add onHover state for actions fix(legend): add legendActionOnHover option to show actions on hover Jan 30, 2026
@elastic-datavis
Copy link
Copy Markdown
Contributor

@markov00 markov00 changed the title fix(legend): add legendActionOnHover option to show actions on hover feat(legend): add legendActionOnHover option to show actions on hover Feb 12, 2026
Copy link
Copy Markdown
Collaborator

@markov00 markov00 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM thanks for all the changes and cleanups.
I've also changed the title to feat instead of fix to better align with the actual content of this PR.
Please verify during the merge that the commit title reflect correctly the changed title.

@elastic elastic deleted a comment from maryam-saeidi Feb 12, 2026
@elastic elastic deleted a comment from maryam-saeidi Feb 12, 2026
@maryam-saeidi maryam-saeidi merged commit d1be88f into elastic:main Feb 12, 2026
14 checks passed
@maryam-saeidi maryam-saeidi deleted the 2444-filter-on-hover branch February 12, 2026 13:37
nickofthyme pushed a commit that referenced this pull request Feb 26, 2026
# [71.2.0](v71.1.2...v71.2.0) (2026-02-26)

### Bug Fixes

* **metric:** update badge to pill shape with adjusted padding ([#2786](#2786)) ([80be269](80be269))
* **theme:** expose font weight in text style ([#2788](#2788)) ([02f4afa](02f4afa))

### Features

* **legend:** add "list" layout for horizontal legends ([#2784](#2784)) ([8967ce3](8967ce3))
* **legend:** add legendActionOnHover option to show actions on hover ([#2773](#2773)) ([d1be88f](d1be88f))
maryam-saeidi added a commit to elastic/kibana that referenced this pull request Feb 27, 2026
## Summary

This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [@elastic/charts](https://togithub.com/elastic/elastic-charts) |
dependencies | minor | [`71.1.2` ->
`71.2.0`](elastic/elastic-charts@v71.1.2...v71.2.0)
|


---

### Release Notes
##
[71.2.0](elastic/elastic-charts@v71.1.2...v71.2.0)
(2026-02-26)


### Bug Fixes

* **metric:** update badge to pill shape with adjusted padding
([#2786](elastic/elastic-charts#2786))
([80be269](elastic/elastic-charts@80be269))
* **theme:** expose font weight in text style
([#2788](elastic/elastic-charts#2788))
([02f4afa](elastic/elastic-charts@02f4afa))


### Features

* **legend:** add "list" layout for horizontal legends
([#2784](elastic/elastic-charts#2784))
([8967ce3](elastic/elastic-charts@8967ce3))
* **legend:** add legendActionOnHover option to show actions on hover
([#2773](elastic/elastic-charts#2773))
([d1be88f](elastic/elastic-charts@d1be88f))
qn895 pushed a commit to qn895/kibana that referenced this pull request Mar 11, 2026
## Summary

This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [@elastic/charts](https://togithub.com/elastic/elastic-charts) |
dependencies | minor | [`71.1.2` ->
`71.2.0`](elastic/elastic-charts@v71.1.2...v71.2.0)
|


---

### Release Notes
##
[71.2.0](elastic/elastic-charts@v71.1.2...v71.2.0)
(2026-02-26)


### Bug Fixes

* **metric:** update badge to pill shape with adjusted padding
([elastic#2786](elastic/elastic-charts#2786))
([80be269](elastic/elastic-charts@80be269))
* **theme:** expose font weight in text style
([elastic#2788](elastic/elastic-charts#2788))
([02f4afa](elastic/elastic-charts@02f4afa))


### Features

* **legend:** add "list" layout for horizontal legends
([elastic#2784](elastic/elastic-charts#2784))
([8967ce3](elastic/elastic-charts@8967ce3))
* **legend:** add legendActionOnHover option to show actions on hover
([elastic#2773](elastic/elastic-charts#2773))
([d1be88f](elastic/elastic-charts@d1be88f))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

:legend Legend related issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Legend] Show data series icon for filters only at hover

3 participants