From 384baace93f0f542d55f3d145006f7a51eb873b0 Mon Sep 17 00:00:00 2001 From: Marco Liberati Date: Fri, 17 May 2024 10:34:05 +0200 Subject: [PATCH] feat(legend): Improve interactions legend labels (#2418) * :sparkles: First draft * :sparkles: Offer new api for interaction labels * :wrench: Tweak story * :wrench: Fix checks * test(vrt): update screenshots [skip ci] * :white_check_mark: Fix test * :bug: Fix issue * :white_check_mark: Add test * :camera_flash: Update snapshots * :fire: Remove api for labels * :fire: Remove prop fro Settings * :fire: Update doc * :camera_flash: Update snapshots * :sparkles: Make label aware of outer context * :camera_flash: Update snapshots * :white_check_mark: Add test to check interactive title on various scenarios --------- Co-authored-by: elastic-datavis[bot] <98618603+elastic-datavis[bot]@users.noreply.github.com> --- ...end-item-interaction-help-chrome-linux.png | Bin 0 -> 14679 bytes e2e/tests/legend_stories.test.ts | 46 ++++++++++- .../__snapshots__/chart.test.tsx.snap | 4 +- .../legend/__snapshots__/legend.test.tsx.snap | 72 +++++++++--------- .../charts/src/components/legend/label.tsx | 47 ++++++++++-- .../charts/src/components/legend/legend.tsx | 1 + .../src/components/legend/legend_item.tsx | 4 + 7 files changed, 130 insertions(+), 44 deletions(-) create mode 100644 e2e/screenshots/all.test.ts-snapshots/baselines/legend/legend-item-interaction-help-chrome-linux.png diff --git a/e2e/screenshots/all.test.ts-snapshots/baselines/legend/legend-item-interaction-help-chrome-linux.png b/e2e/screenshots/all.test.ts-snapshots/baselines/legend/legend-item-interaction-help-chrome-linux.png new file mode 100644 index 0000000000000000000000000000000000000000..c557f23cb8f441e751e3cc5e2a3530f953e095b3 GIT binary patch literal 14679 zcmc(GcUV*Dwmy!>h63XVqSQf9mK}17SI?@S6Y9J6$ z5fB1`K!}u3r6eKLgc1n+zBuQcTW0Ru^W0ziBhP-4?7hFb)_T{w-tVcgp$;1>4=W1` z3mZiD7gH9NABZe02i%Sx2EUNrxsbu-K!B;vb(ZqaeBhs-Ss=e$GrylsA;9i)(ni`> zL-gUgKL|zrbd+C0ui_z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_D}BaYDraY#Y}acXGQOq65NE8tgIyf_{`#CZ2;bgbamTU25s5KoxhYe)g=KdM>xaZkFhnrp-kt*<-i9 zkyf$3lMz@kzp<3#fI)kHnKnvHMcW%0hFPCliui?jxaaVR1td78!aR4>*49RPLXIZa z;^!CM9Pi!y+Od6b$DQHJt3YWuD=95)dcE~9+@I761eQC|6(TI}?7+dT*)`}XkP@&w i2S+f#<^ME0y&XZC{bcTXOc~8=1fpg5OZoL*AO0^9OZoi( literal 0 HcmV?d00001 diff --git a/e2e/tests/legend_stories.test.ts b/e2e/tests/legend_stories.test.ts index a5ddee3a1d..c41970e1e6 100644 --- a/e2e/tests/legend_stories.test.ts +++ b/e2e/tests/legend_stories.test.ts @@ -182,12 +182,56 @@ test.describe('Legend stories', () => { Array.from(document.getElementsByClassName('echLegendItem'), (e) => e.outerHTML), ); (await labels).forEach((label, index) => { - if (label.includes('Activate to show series')) { + const ariaInteractionLabel = label.split('; ')[1]; + if (ariaInteractionLabel && /show/.test(ariaInteractionLabel)) { hiddenResults.push(index); } }); expect(hiddenResults).toEqual([1]); }); + + test('title interactive help should change according to the legend context for the item', async ({ page }) => { + await common.loadElementFromURL(page)( + 'http://localhost:9001/?path=/story/legend--positioning&knob-position=right', + '.echLegendItem__label', + ); + + // check that the first item has a "isolate" title as second line + const initialLabels = await page.evaluate(() => + Array.from(document.getElementsByClassName('echLegendItem__label'), (e) => e.getAttribute('title')), + ); + + expect(initialLabels.map((label) => (label ? label.split('\n')[1] : ''))).toEqual( + new Array(initialLabels.length).fill('Click: isolate series'), + ); + + // click on the first item + await page.keyboard.press('Tab'); + await page.keyboard.press(`Enter`); + + // now check that it has a "show all" title this time + // check that all the other items (hidden) have a "show" title + const secondRoundLabels = await page.evaluate(() => + Array.from(document.getElementsByClassName('echLegendItem__label'), (e) => e.getAttribute('title')), + ); + expect(secondRoundLabels.map((label) => (label ? label.split('\n')[1] : ''))).toEqual( + ['Click: show all series'].concat(new Array(secondRoundLabels.length - 1).fill('Click: show series')), + ); + + // now click on the second item (hidden) + await page.keyboard.press('Tab'); + await page.keyboard.press(`Enter`); + + // check that the first two items have a "hide" title and the rest have a "show" title + const thirdRoundLabels = await page.evaluate(() => + Array.from(document.getElementsByClassName('echLegendItem__label'), (e) => e.getAttribute('title')), + ); + expect(thirdRoundLabels.map((label) => (label ? label.split('\n')[1] : ''))).toEqual( + ['Click: hide series', 'Click: hide series'].concat( + new Array(secondRoundLabels.length - 2).fill('Click: show series'), + ), + ); + }); }); test.describe('Extra values', () => { diff --git a/packages/charts/src/components/__snapshots__/chart.test.tsx.snap b/packages/charts/src/components/__snapshots__/chart.test.tsx.snap index 3695910d87..635170f314 100644 --- a/packages/charts/src/components/__snapshots__/chart.test.tsx.snap +++ b/packages/charts/src/components/__snapshots__/chart.test.tsx.snap @@ -26,7 +26,7 @@ exports[`Chart should render the legend name test 1`] = `

    - +
  • @@ -42,7 +42,7 @@ exports[`Chart should render the legend name test 1`] = `
    -
  • @@ -17,13 +17,13 @@ exports[`Legend #legendColorPicker should match snapshot after onChange is calle
    -
  • -
    +
  • @@ -39,13 +39,13 @@ exports[`Legend #legendColorPicker should match snapshot after onChange is calle
    -
  • -
    +
  • @@ -61,13 +61,13 @@ exports[`Legend #legendColorPicker should match snapshot after onChange is calle
    -
  • -
    +
  • @@ -83,8 +83,8 @@ exports[`Legend #legendColorPicker should match snapshot after onChange is calle
    -
  • @@ -109,13 +109,13 @@ exports[`Legend #legendColorPicker should match snapshot after onClose is called
    -
  • -
    +
  • @@ -131,13 +131,13 @@ exports[`Legend #legendColorPicker should match snapshot after onClose is called
    -
  • -
    +
  • @@ -153,13 +153,13 @@ exports[`Legend #legendColorPicker should match snapshot after onClose is called
    -
  • -
    +
  • @@ -175,8 +175,8 @@ exports[`Legend #legendColorPicker should match snapshot after onClose is called
    -
  • @@ -215,8 +215,8 @@ exports[`Legend #legendColorPicker should render colorPicker when color is click
    -
  • @@ -250,13 +250,13 @@ exports[`Legend #legendColorPicker should render colorPicker when color is click
    -
  • -
    +
  • @@ -272,13 +272,13 @@ exports[`Legend #legendColorPicker should render colorPicker when color is click
    -
  • -
    +
  • @@ -294,8 +294,8 @@ exports[`Legend #legendColorPicker should render colorPicker when color is click
    -