Skip to content

Commit 95b80a6

Browse files
committed
2 parents 92a176f + 47eee4c commit 95b80a6

File tree

3 files changed

+22
-24
lines changed

3 files changed

+22
-24
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,12 @@ documentation of this starter for understanding the lifecycle of this repo.
121121

122122
A few projects that use `@codegouvfr/react-dsfr`.
123123

124-
- https://sill.code.gouv.fr
124+
- https://code.gouv.fr/sill
125125
- https://immersion-facile.beta.gouv.fr/
126126
- https://refugies.info/fr
127127
- https://www.mediateur-public.fr/
128128
- https://signal.conso.gouv.fr/
129+
- https://observatoire.numerique.gouv.fr/
129130
- https://github.com/BaseAdresseNationale/adresse.data.gouv.fr
130131
- https://github.com/DISIC/observatoire.numerique.gouv.fr
131132
- https://github.com/DISIC/monfranceconnect

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@codegouvfr/react-dsfr",
3-
"version": "0.75.0",
3+
"version": "0.75.3",
44
"description": "French State Design System React integration library",
55
"repository": {
66
"type": "git",

src/Tabs.tsx

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -108,31 +108,28 @@ export const Tabs = memo(
108108
const onKeyboardNavigation = (
109109
event: React.KeyboardEvent<HTMLButtonElement> | React.KeyboardEvent<HTMLUListElement>
110110
) => {
111-
let targetIndex = selectedTabIndex;
112-
switch (event.key) {
113-
case "ArrowRight":
114-
targetIndex = selectedTabIndex < tabs.length - 1 ? selectedTabIndex + 1 : 0;
115-
break;
116-
case "ArrowLeft":
117-
targetIndex = selectedTabIndex === 0 ? tabs.length - 1 : selectedTabIndex - 1;
118-
break;
119-
case "Home":
120-
targetIndex = 0;
121-
break;
122-
case "End":
123-
targetIndex = tabs.length - 1;
124-
break;
111+
if (selectedTabId !== undefined) {
112+
let targetIndex = selectedTabIndex;
113+
switch (event.key) {
114+
case "ArrowRight":
115+
targetIndex = selectedTabIndex < tabs.length - 1 ? selectedTabIndex + 1 : 0;
116+
break;
117+
case "ArrowLeft":
118+
targetIndex =
119+
selectedTabIndex === 0 ? tabs.length - 1 : selectedTabIndex - 1;
120+
break;
121+
case "Home":
122+
targetIndex = 0;
123+
break;
124+
case "End":
125+
targetIndex = tabs.length - 1;
126+
break;
127+
}
128+
buttonRefs.current[targetIndex]?.click();
129+
buttonRefs.current[targetIndex]?.focus();
125130
}
126-
buttonRefs.current[targetIndex]?.click();
127131
};
128132

129-
React.useEffect(() => {
130-
const targetTabButton = buttonRefs.current[selectedTabIndex];
131-
if (targetTabButton) {
132-
targetTabButton.focus();
133-
}
134-
}, [selectedTabIndex]);
135-
136133
const { getPanelId, getTabId } = (function useClosure() {
137134
const id = useId();
138135

0 commit comments

Comments
 (0)