@kaizen/components 1.68.4 → 1.68.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/dist/cjs/Tile/subcomponents/GenericTile/GenericTile.cjs +23 -2
  2. package/dist/esm/Tile/subcomponents/GenericTile/GenericTile.mjs +24 -3
  3. package/dist/styles.css +79 -79
  4. package/locales/ar.json +8 -0
  5. package/locales/bg.json +8 -0
  6. package/locales/cs.json +8 -0
  7. package/locales/cy.json +8 -0
  8. package/locales/da.json +8 -0
  9. package/locales/de.json +8 -0
  10. package/locales/el.json +8 -0
  11. package/locales/en-GB.json +8 -0
  12. package/locales/es-419.json +8 -0
  13. package/locales/es.json +8 -0
  14. package/locales/et.json +8 -0
  15. package/locales/fi.json +8 -0
  16. package/locales/fr-CA.json +8 -0
  17. package/locales/fr.json +8 -0
  18. package/locales/he.json +8 -0
  19. package/locales/hi.json +8 -0
  20. package/locales/ht.json +8 -0
  21. package/locales/hu.json +8 -0
  22. package/locales/id.json +8 -0
  23. package/locales/it.json +8 -0
  24. package/locales/ja.json +8 -0
  25. package/locales/km-KH.json +8 -0
  26. package/locales/ko.json +8 -0
  27. package/locales/lt.json +8 -0
  28. package/locales/lv.json +8 -0
  29. package/locales/mi.json +8 -0
  30. package/locales/ms.json +8 -0
  31. package/locales/nb.json +8 -0
  32. package/locales/nl.json +8 -0
  33. package/locales/pl.json +8 -0
  34. package/locales/pt-BR.json +8 -0
  35. package/locales/pt.json +8 -0
  36. package/locales/ro.json +8 -0
  37. package/locales/ru.json +8 -0
  38. package/locales/si-LK.json +8 -0
  39. package/locales/sk.json +8 -0
  40. package/locales/sr.json +8 -0
  41. package/locales/sv.json +8 -0
  42. package/locales/th.json +8 -0
  43. package/locales/tl.json +8 -0
  44. package/locales/tr.json +8 -0
  45. package/locales/uk.json +8 -0
  46. package/locales/vi.json +8 -0
  47. package/locales/zh-TW.json +8 -0
  48. package/locales/zh.json +8 -0
  49. package/package.json +1 -1
  50. package/src/Tile/TileGrid/_docs/TileGrid.stories.tsx +41 -8
  51. package/src/Tile/subcomponents/GenericTile/GenericTile.spec.stories.tsx +58 -0
  52. package/src/Tile/subcomponents/GenericTile/GenericTile.tsx +24 -1
@@ -164,6 +164,14 @@
164
164
  "description" : "Home button label",
165
165
  "message" : "ទៅកាន់ទំព័រដើម"
166
166
  },
167
+ "kzGenericTile.infoButtonLabel" : {
168
+ "description" : "Prompts user to interact with button to reveal more information",
169
+ "message" : "មើលព័ត៌មានបន្ថែម៖"
170
+ },
171
+ "kzGenericTile.infoButtonReturnLabel" : {
172
+ "description" : "Prompts user to interact with button to hide information",
173
+ "message" : "លាក់ព័ត៌មាន៖"
174
+ },
167
175
  "splitButton.dropdownButton.label" : {
168
176
  "description" : "Label for a dropdown menu holding additional actions",
169
177
  "message" : "សកម្មភាពបន្ថែម"
package/locales/ko.json CHANGED
@@ -164,6 +164,14 @@
164
164
  "description" : "Home button label",
165
165
  "message" : "홈으로 이동하기"
166
166
  },
167
+ "kzGenericTile.infoButtonLabel" : {
168
+ "description" : "Prompts user to interact with button to reveal more information",
169
+ "message" : "자세한 정보 보기:"
170
+ },
171
+ "kzGenericTile.infoButtonReturnLabel" : {
172
+ "description" : "Prompts user to interact with button to hide information",
173
+ "message" : "정보 숨기기:"
174
+ },
167
175
  "splitButton.dropdownButton.label" : {
168
176
  "description" : "Label for a dropdown menu holding additional actions",
169
177
  "message" : "추가 작업"
package/locales/lt.json CHANGED
@@ -164,6 +164,14 @@
164
164
  "description" : "Home button label",
165
165
  "message" : "Eiti į pagrindinį puslapį"
166
166
  },
167
+ "kzGenericTile.infoButtonLabel" : {
168
+ "description" : "Prompts user to interact with button to reveal more information",
169
+ "message" : "Žiūrėti daugiau informacijos:"
170
+ },
171
+ "kzGenericTile.infoButtonReturnLabel" : {
172
+ "description" : "Prompts user to interact with button to hide information",
173
+ "message" : "Paslėpti informaciją:"
174
+ },
167
175
  "splitButton.dropdownButton.label" : {
168
176
  "description" : "Label for a dropdown menu holding additional actions",
169
177
  "message" : "Papildomi veiksmai"
package/locales/lv.json CHANGED
@@ -164,6 +164,14 @@
164
164
  "description" : "Home button label",
165
165
  "message" : "Doties uz sākumlapu"
166
166
  },
167
+ "kzGenericTile.infoButtonLabel" : {
168
+ "description" : "Prompts user to interact with button to reveal more information",
169
+ "message" : "Skatīt vairāk informācijas:"
170
+ },
171
+ "kzGenericTile.infoButtonReturnLabel" : {
172
+ "description" : "Prompts user to interact with button to hide information",
173
+ "message" : "Paslēpt informāciju:"
174
+ },
167
175
  "splitButton.dropdownButton.label" : {
168
176
  "description" : "Label for a dropdown menu holding additional actions",
169
177
  "message" : "Papildu darbības"
package/locales/mi.json CHANGED
@@ -164,6 +164,14 @@
164
164
  "description" : "Home button label",
165
165
  "message" : "Go to Home"
166
166
  },
167
+ "kzGenericTile.infoButtonLabel" : {
168
+ "description" : "Prompts user to interact with button to reveal more information",
169
+ "message" : "Tirohia etahi atu korero:"
170
+ },
171
+ "kzGenericTile.infoButtonReturnLabel" : {
172
+ "description" : "Prompts user to interact with button to hide information",
173
+ "message" : "Huna mōhiohio:"
174
+ },
167
175
  "splitButton.dropdownButton.label" : {
168
176
  "description" : "Label for a dropdown menu holding additional actions",
169
177
  "message" : "Ngā mahi tāpiri"
package/locales/ms.json CHANGED
@@ -164,6 +164,14 @@
164
164
  "description" : "Home button label",
165
165
  "message" : "Pergi kepada Laman Utama"
166
166
  },
167
+ "kzGenericTile.infoButtonLabel" : {
168
+ "description" : "Prompts user to interact with button to reveal more information",
169
+ "message" : "Lihat maklumat lanjut:"
170
+ },
171
+ "kzGenericTile.infoButtonReturnLabel" : {
172
+ "description" : "Prompts user to interact with button to hide information",
173
+ "message" : "Sembunyikan maklumat:"
174
+ },
167
175
  "splitButton.dropdownButton.label" : {
168
176
  "description" : "Label for a dropdown menu holding additional actions",
169
177
  "message" : "Tindakan tambahan"
package/locales/nb.json CHANGED
@@ -164,6 +164,14 @@
164
164
  "description" : "Home button label",
165
165
  "message" : "Gå til Hjem"
166
166
  },
167
+ "kzGenericTile.infoButtonLabel" : {
168
+ "description" : "Prompts user to interact with button to reveal more information",
169
+ "message" : "Vis mer informasjon:"
170
+ },
171
+ "kzGenericTile.infoButtonReturnLabel" : {
172
+ "description" : "Prompts user to interact with button to hide information",
173
+ "message" : "Skjul informasjon:"
174
+ },
167
175
  "splitButton.dropdownButton.label" : {
168
176
  "description" : "Label for a dropdown menu holding additional actions",
169
177
  "message" : "Ytterligere handlinger"
package/locales/nl.json CHANGED
@@ -164,6 +164,14 @@
164
164
  "description" : "Home button label",
165
165
  "message" : "Naar startpagina"
166
166
  },
167
+ "kzGenericTile.infoButtonLabel" : {
168
+ "description" : "Prompts user to interact with button to reveal more information",
169
+ "message" : "Bekijk meer informatie:"
170
+ },
171
+ "kzGenericTile.infoButtonReturnLabel" : {
172
+ "description" : "Prompts user to interact with button to hide information",
173
+ "message" : "Informatie verbergen:"
174
+ },
167
175
  "splitButton.dropdownButton.label" : {
168
176
  "description" : "Label for a dropdown menu holding additional actions",
169
177
  "message" : "Meer acties"
package/locales/pl.json CHANGED
@@ -164,6 +164,14 @@
164
164
  "description" : "Home button label",
165
165
  "message" : "Przejdź do strony głównej"
166
166
  },
167
+ "kzGenericTile.infoButtonLabel" : {
168
+ "description" : "Prompts user to interact with button to reveal more information",
169
+ "message" : "Zobacz więcej informacji:"
170
+ },
171
+ "kzGenericTile.infoButtonReturnLabel" : {
172
+ "description" : "Prompts user to interact with button to hide information",
173
+ "message" : "Ukryj informacje:"
174
+ },
167
175
  "splitButton.dropdownButton.label" : {
168
176
  "description" : "Label for a dropdown menu holding additional actions",
169
177
  "message" : "Dodatkowe działania"
@@ -164,6 +164,14 @@
164
164
  "description" : "Home button label",
165
165
  "message" : "Acessar página inicial"
166
166
  },
167
+ "kzGenericTile.infoButtonLabel" : {
168
+ "description" : "Prompts user to interact with button to reveal more information",
169
+ "message" : "Ver mais informações:"
170
+ },
171
+ "kzGenericTile.infoButtonReturnLabel" : {
172
+ "description" : "Prompts user to interact with button to hide information",
173
+ "message" : "Ocultar informações:"
174
+ },
167
175
  "splitButton.dropdownButton.label" : {
168
176
  "description" : "Label for a dropdown menu holding additional actions",
169
177
  "message" : "Mais ações"
package/locales/pt.json CHANGED
@@ -164,6 +164,14 @@
164
164
  "description" : "Home button label",
165
165
  "message" : "Acessar página inicial"
166
166
  },
167
+ "kzGenericTile.infoButtonLabel" : {
168
+ "description" : "Prompts user to interact with button to reveal more information",
169
+ "message" : "Ver mais informações:"
170
+ },
171
+ "kzGenericTile.infoButtonReturnLabel" : {
172
+ "description" : "Prompts user to interact with button to hide information",
173
+ "message" : "Ocultar informações:"
174
+ },
167
175
  "splitButton.dropdownButton.label" : {
168
176
  "description" : "Label for a dropdown menu holding additional actions",
169
177
  "message" : "Mais ações"
package/locales/ro.json CHANGED
@@ -164,6 +164,14 @@
164
164
  "description" : "Home button label",
165
165
  "message" : "Mergeți la pagina principală"
166
166
  },
167
+ "kzGenericTile.infoButtonLabel" : {
168
+ "description" : "Prompts user to interact with button to reveal more information",
169
+ "message" : "Vedeți mai multe informații:"
170
+ },
171
+ "kzGenericTile.infoButtonReturnLabel" : {
172
+ "description" : "Prompts user to interact with button to hide information",
173
+ "message" : "Ascundeți informațiile:"
174
+ },
167
175
  "splitButton.dropdownButton.label" : {
168
176
  "description" : "Label for a dropdown menu holding additional actions",
169
177
  "message" : "Acțiuni suplimentare"
package/locales/ru.json CHANGED
@@ -164,6 +164,14 @@
164
164
  "description" : "Home button label",
165
165
  "message" : "Перейти на главную"
166
166
  },
167
+ "kzGenericTile.infoButtonLabel" : {
168
+ "description" : "Prompts user to interact with button to reveal more information",
169
+ "message" : "Показать дополнительную информацию:"
170
+ },
171
+ "kzGenericTile.infoButtonReturnLabel" : {
172
+ "description" : "Prompts user to interact with button to hide information",
173
+ "message" : "Скрыть информацию:"
174
+ },
167
175
  "splitButton.dropdownButton.label" : {
168
176
  "description" : "Label for a dropdown menu holding additional actions",
169
177
  "message" : "Дополнительные действия"
@@ -164,6 +164,14 @@
164
164
  "description" : "Home button label",
165
165
  "message" : "ගෙදර යන්න"
166
166
  },
167
+ "kzGenericTile.infoButtonLabel" : {
168
+ "description" : "Prompts user to interact with button to reveal more information",
169
+ "message" : "වැඩි විස්තර බලන්න:"
170
+ },
171
+ "kzGenericTile.infoButtonReturnLabel" : {
172
+ "description" : "Prompts user to interact with button to hide information",
173
+ "message" : "තොරතුරු සඟවන්න:"
174
+ },
167
175
  "splitButton.dropdownButton.label" : {
168
176
  "description" : "Label for a dropdown menu holding additional actions",
169
177
  "message" : "අතිරේක ක්‍රියාමාර්ග"
package/locales/sk.json CHANGED
@@ -164,6 +164,14 @@
164
164
  "description" : "Home button label",
165
165
  "message" : "Prejsť na Úvod"
166
166
  },
167
+ "kzGenericTile.infoButtonLabel" : {
168
+ "description" : "Prompts user to interact with button to reveal more information",
169
+ "message" : "Zobraziť viac informácií:"
170
+ },
171
+ "kzGenericTile.infoButtonReturnLabel" : {
172
+ "description" : "Prompts user to interact with button to hide information",
173
+ "message" : "Skryť informácie:"
174
+ },
167
175
  "splitButton.dropdownButton.label" : {
168
176
  "description" : "Label for a dropdown menu holding additional actions",
169
177
  "message" : "Ďalšie činnosti"
package/locales/sr.json CHANGED
@@ -164,6 +164,14 @@
164
164
  "description" : "Home button label",
165
165
  "message" : "Idite na Početnu stranicu"
166
166
  },
167
+ "kzGenericTile.infoButtonLabel" : {
168
+ "description" : "Prompts user to interact with button to reveal more information",
169
+ "message" : "Pogledaj više informacija:"
170
+ },
171
+ "kzGenericTile.infoButtonReturnLabel" : {
172
+ "description" : "Prompts user to interact with button to hide information",
173
+ "message" : "Sakrij informacije:"
174
+ },
167
175
  "splitButton.dropdownButton.label" : {
168
176
  "description" : "Label for a dropdown menu holding additional actions",
169
177
  "message" : "Dodatne radnje"
package/locales/sv.json CHANGED
@@ -164,6 +164,14 @@
164
164
  "description" : "Home button label",
165
165
  "message" : "Gå till startsidan"
166
166
  },
167
+ "kzGenericTile.infoButtonLabel" : {
168
+ "description" : "Prompts user to interact with button to reveal more information",
169
+ "message" : "Visa mer information:"
170
+ },
171
+ "kzGenericTile.infoButtonReturnLabel" : {
172
+ "description" : "Prompts user to interact with button to hide information",
173
+ "message" : "Dölj information:"
174
+ },
167
175
  "splitButton.dropdownButton.label" : {
168
176
  "description" : "Label for a dropdown menu holding additional actions",
169
177
  "message" : "Ytterligare åtgärder"
package/locales/th.json CHANGED
@@ -164,6 +164,14 @@
164
164
  "description" : "Home button label",
165
165
  "message" : "ไปที่หน้าแรก"
166
166
  },
167
+ "kzGenericTile.infoButtonLabel" : {
168
+ "description" : "Prompts user to interact with button to reveal more information",
169
+ "message" : "ดูข้อมูลเพิ่มเติม:"
170
+ },
171
+ "kzGenericTile.infoButtonReturnLabel" : {
172
+ "description" : "Prompts user to interact with button to hide information",
173
+ "message" : "ซ่อนข้อมูล:"
174
+ },
167
175
  "splitButton.dropdownButton.label" : {
168
176
  "description" : "Label for a dropdown menu holding additional actions",
169
177
  "message" : "การดำเนินการเพิ่มเติม"
package/locales/tl.json CHANGED
@@ -164,6 +164,14 @@
164
164
  "description" : "Home button label",
165
165
  "message" : "Pumunta sa Home"
166
166
  },
167
+ "kzGenericTile.infoButtonLabel" : {
168
+ "description" : "Prompts user to interact with button to reveal more information",
169
+ "message" : "Tingnan ang iba pang impormasyon"
170
+ },
171
+ "kzGenericTile.infoButtonReturnLabel" : {
172
+ "description" : "Prompts user to interact with button to hide information",
173
+ "message" : "Itago ang impormasyon:"
174
+ },
167
175
  "splitButton.dropdownButton.label" : {
168
176
  "description" : "Label for a dropdown menu holding additional actions",
169
177
  "message" : "Karagdagang mga aksiyon"
package/locales/tr.json CHANGED
@@ -164,6 +164,14 @@
164
164
  "description" : "Home button label",
165
165
  "message" : "Ana Sayfaya Git"
166
166
  },
167
+ "kzGenericTile.infoButtonLabel" : {
168
+ "description" : "Prompts user to interact with button to reveal more information",
169
+ "message" : "Daha fazla bilgi görüntüleyin:"
170
+ },
171
+ "kzGenericTile.infoButtonReturnLabel" : {
172
+ "description" : "Prompts user to interact with button to hide information",
173
+ "message" : "Bilgileri gizleyin:"
174
+ },
167
175
  "splitButton.dropdownButton.label" : {
168
176
  "description" : "Label for a dropdown menu holding additional actions",
169
177
  "message" : "Ek eylemler"
package/locales/uk.json CHANGED
@@ -164,6 +164,14 @@
164
164
  "description" : "Home button label",
165
165
  "message" : "Перейти на головну"
166
166
  },
167
+ "kzGenericTile.infoButtonLabel" : {
168
+ "description" : "Prompts user to interact with button to reveal more information",
169
+ "message" : "Переглянути додаткову інформацію:"
170
+ },
171
+ "kzGenericTile.infoButtonReturnLabel" : {
172
+ "description" : "Prompts user to interact with button to hide information",
173
+ "message" : "Приховати інформацію:"
174
+ },
167
175
  "splitButton.dropdownButton.label" : {
168
176
  "description" : "Label for a dropdown menu holding additional actions",
169
177
  "message" : "Додаткові дії"
package/locales/vi.json CHANGED
@@ -164,6 +164,14 @@
164
164
  "description" : "Home button label",
165
165
  "message" : "Vào Trang chủ"
166
166
  },
167
+ "kzGenericTile.infoButtonLabel" : {
168
+ "description" : "Prompts user to interact with button to reveal more information",
169
+ "message" : "Xem thêm thông tin:"
170
+ },
171
+ "kzGenericTile.infoButtonReturnLabel" : {
172
+ "description" : "Prompts user to interact with button to hide information",
173
+ "message" : "Ẩn thông tin:"
174
+ },
167
175
  "splitButton.dropdownButton.label" : {
168
176
  "description" : "Label for a dropdown menu holding additional actions",
169
177
  "message" : "Các hành động bổ sung"
@@ -164,6 +164,14 @@
164
164
  "description" : "Home button label",
165
165
  "message" : "前往首頁"
166
166
  },
167
+ "kzGenericTile.infoButtonLabel" : {
168
+ "description" : "Prompts user to interact with button to reveal more information",
169
+ "message" : "檢視更多資訊:"
170
+ },
171
+ "kzGenericTile.infoButtonReturnLabel" : {
172
+ "description" : "Prompts user to interact with button to hide information",
173
+ "message" : "隱藏資訊:"
174
+ },
167
175
  "splitButton.dropdownButton.label" : {
168
176
  "description" : "Label for a dropdown menu holding additional actions",
169
177
  "message" : "其他行動"
package/locales/zh.json CHANGED
@@ -164,6 +164,14 @@
164
164
  "description" : "Home button label",
165
165
  "message" : "转到主页"
166
166
  },
167
+ "kzGenericTile.infoButtonLabel" : {
168
+ "description" : "Prompts user to interact with button to reveal more information",
169
+ "message" : "查看更多信息:"
170
+ },
171
+ "kzGenericTile.infoButtonReturnLabel" : {
172
+ "description" : "Prompts user to interact with button to hide information",
173
+ "message" : "隐藏信息:"
174
+ },
167
175
  "splitButton.dropdownButton.label" : {
168
176
  "description" : "Label for a dropdown menu holding additional actions",
169
177
  "message" : "附加操作"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kaizen/components",
3
- "version": "1.68.4",
3
+ "version": "1.68.5",
4
4
  "description": "Kaizen component library",
5
5
  "author": "Geoffrey Chong <geoff.chong@cultureamp.com>",
6
6
  "homepage": "https://cultureamp.design",
@@ -1,5 +1,6 @@
1
1
  import React from "react"
2
2
  import { Meta, StoryObj } from "@storybook/react"
3
+ import { expect, waitFor, within } from "@storybook/test"
3
4
  import { InformationTile } from "~components/Tile"
4
5
  import { TileGrid } from "../index"
5
6
 
@@ -10,21 +11,21 @@ const meta = {
10
11
  children: (
11
12
  <>
12
13
  <InformationTile
13
- title="Title"
14
+ title="Title A"
14
15
  metadata="Side A"
15
- information="Side B"
16
+ information="Side A - Back"
16
17
  footer={<>Footer</>}
17
18
  />
18
19
  <InformationTile
19
- title="Title"
20
- metadata="Side A"
21
- information="Side B"
20
+ title="Title B"
21
+ metadata="Side B"
22
+ information="Side B - Back"
22
23
  footer={<>Footer</>}
23
24
  />
24
25
  <InformationTile
25
- title="Title"
26
- metadata="Side A"
27
- information="Side B"
26
+ title="Title C"
27
+ metadata="Side C"
28
+ information="Side C - Back"
28
29
  footer={<>Footer</>}
29
30
  />
30
31
  </>
@@ -45,3 +46,35 @@ export const Playground: Story = {
45
46
  },
46
47
  },
47
48
  }
49
+
50
+ // Test for multiple tiles, flipping one doesn't flip others
51
+ export const FlipOneNotOthers: Story = {
52
+ play: async ({ canvasElement, step }) => {
53
+ const canvas = within(canvasElement)
54
+
55
+ await step("initial render complete", async () => {
56
+ await waitFor(() => {
57
+ canvas.getByRole("button", {
58
+ name: "View more information: Title A",
59
+ })
60
+ })
61
+ })
62
+
63
+ await step("Can focus to button", async () => {
64
+ await waitFor(() => {
65
+ const buttonWithInfoLabel = canvas.getByRole("button", {
66
+ name: "View more information: Title A",
67
+ })
68
+ buttonWithInfoLabel.click()
69
+ })
70
+ })
71
+
72
+ await step("Check other tiles", async () => {
73
+ await waitFor(() => {
74
+ expect(canvas.getByText("Side A - Back")).toBeInTheDocument()
75
+ expect(canvas.getByText("Title B")).toBeInTheDocument()
76
+ expect(canvas.getByText("Title C")).toBeInTheDocument()
77
+ })
78
+ })
79
+ },
80
+ }
@@ -87,3 +87,61 @@ export const InfoButtonLabel: Story = {
87
87
  })
88
88
  },
89
89
  }
90
+
91
+ export const DoesNotStealFocusOnInitialRender: Story = {
92
+ play: async ({ canvasElement, step }) => {
93
+ const canvas = within(canvasElement)
94
+
95
+ await step("initial render complete", async () => {
96
+ await waitFor(() => {
97
+ canvas.getByRole("button", {
98
+ name: "View more information: Title",
99
+ })
100
+ })
101
+ })
102
+
103
+ await step("Can focus to button", async () => {
104
+ await waitFor(() => {
105
+ const buttonWithInfoLabel = canvas.getByRole("button", {
106
+ name: "View more information: Title",
107
+ })
108
+ expect(buttonWithInfoLabel).not.toHaveFocus()
109
+ })
110
+ })
111
+ },
112
+ }
113
+
114
+ export const FocusOnFlip: Story = {
115
+ play: async ({ canvasElement, step }) => {
116
+ const canvas = within(canvasElement)
117
+ const buttonWithInfoLabel = await canvas.findByRole("button", {
118
+ name: "View more information: Title",
119
+ })
120
+
121
+ await step("initial render complete", async () => {
122
+ expect(buttonWithInfoLabel).toBeInTheDocument()
123
+ })
124
+
125
+ await step("Can focus to button", async () => {
126
+ await waitFor(() => {
127
+ buttonWithInfoLabel.click()
128
+ })
129
+ })
130
+
131
+ const returnButton = canvas.getByRole("button", {
132
+ name: "Hide information: Title",
133
+ })
134
+
135
+ await step("Can click on info button again", async () => {
136
+ await waitFor(() => {
137
+ returnButton.click()
138
+ })
139
+ })
140
+
141
+ await step("Info button has focus again", async () => {
142
+ await waitFor(() => {
143
+ expect(buttonWithInfoLabel).toHaveFocus()
144
+ })
145
+ })
146
+ },
147
+ }
@@ -1,4 +1,4 @@
1
- import React, { HTMLAttributes, useState } from "react"
1
+ import React, { HTMLAttributes, useState, useRef, useEffect } from "react"
2
2
  import { useIntl } from "@cultureamp/i18n-react-intl"
3
3
  import classnames from "classnames"
4
4
  import { AllowedHeadingTags, Heading } from "~components/Heading"
@@ -57,7 +57,28 @@ export const GenericTile = ({
57
57
  ...restProps
58
58
  }: GenericTileProps): JSX.Element => {
59
59
  const [isFlipped, setIsFlipped] = useState<boolean>(false)
60
+ const [isDocumentReady, setIsDocumentReady] = useState<boolean>(false)
61
+
60
62
  const { formatMessage } = useIntl()
63
+ const infoButtonRef = useRef<HTMLButtonElement>(null)
64
+ const infoButtonReturnRef = useRef<HTMLButtonElement>(null)
65
+
66
+ useEffect(() => {
67
+ setIsDocumentReady(true)
68
+ }, [])
69
+
70
+ useEffect(() => {
71
+ if (!isDocumentReady) {
72
+ setIsDocumentReady(true)
73
+ return
74
+ }
75
+
76
+ if (isFlipped) {
77
+ infoButtonReturnRef.current!.focus()
78
+ } else {
79
+ infoButtonRef.current!.focus()
80
+ }
81
+ }, [isFlipped])
61
82
 
62
83
  const translatedInfoLabel = formatMessage({
63
84
  id: "kzGenericTile.infoButtonLabel",
@@ -97,6 +118,7 @@ export const GenericTile = ({
97
118
  onClick={(): void => setIsFlipped(true)}
98
119
  disabled={isFlipped}
99
120
  aria-hidden={isFlipped}
121
+ ref={infoButtonRef}
100
122
  />
101
123
  </div>
102
124
  )}
@@ -162,6 +184,7 @@ export const GenericTile = ({
162
184
  onClick={(): void => setIsFlipped(false)}
163
185
  disabled={!isFlipped}
164
186
  aria-hidden={!isFlipped}
187
+ ref={infoButtonReturnRef}
165
188
  />
166
189
  </div>
167
190
  <div className={styles.information}>