Skip to content

Commit 7478319

Browse files
committed
fix: add Enter key support and aria-labels to interactive controls
1 parent 5b79fb7 commit 7478319

4 files changed

Lines changed: 15 additions & 6 deletions

File tree

src/component/FullScreenButton.jsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,11 @@ export default function FullScreenButton() {
1515
};
1616

1717
return (
18-
<button type="button" onClick={toggleFullscreen}>
18+
<button
19+
type="button"
20+
aria-label={isFullscreen ? 'Exit fullscreen' : 'Enter fullscreen'}
21+
onClick={toggleFullscreen}
22+
>
1923
{isFullscreen ? <Minimize size={20} /> : <Maximize size={20} />}
2024
</button>
2125
);

src/component/HeaderComps.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ const Switcher = ({
3737
tabIndex={tabIndex}
3838
className={`tool ${active ? 'active' : ''}`}
3939
onClick={action}
40-
onKeyDown={(ev) => ev.key === ' ' && action()}
40+
onKeyDown={(ev) => (ev.key === ' ' || ev.key === 'Enter') && action()}
4141
>
4242
{Icon && <div className="icon"><Icon size="20" /></div>}
4343
<Switch
@@ -60,7 +60,7 @@ const ActionButton = ({
6060
tabIndex={tabIndex}
6161
className={`tool ${active ? 'active' : ''}`}
6262
onClick={() => (active && action())}
63-
onKeyDown={(ev) => active && ev.key === ' ' && action()}
63+
onKeyDown={(ev) => active && (ev.key === ' ' || ev.key === 'Enter') && action()}
6464
data-tip={hotkey ? hotkey.split(',')[0] : ''}
6565
style={{ display: `${visibility ? '' : 'none'}` }}
6666
>

src/component/TabBar.jsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ const TabBar = ({ superState, dispatcher }) => {
7979
onClick={newProject.bind(this, superState, dispatcher)}
8080
type="button"
8181
id="new_graph"
82+
aria-label="New workflow tab"
8283
data-tip="New Workflow Tab (Ctrl + Shift + M)"
8384
>
8485
<MdAdd size={25} />
@@ -88,7 +89,7 @@ const TabBar = ({ superState, dispatcher }) => {
8889
key={el.graphID}
8990
className={`tab tab-graph ${superState.curGraphIndex === i ? 'selected' : 'none'}`}
9091
onClick={() => dispatcher({ type: T.CHANGE_TAB, payload: i })}
91-
onKeyDown={(ev) => ev.key === ' ' && dispatcher({ type: T.CHANGE_TAB, payload: i })}
92+
onKeyDown={(ev) => (ev.key === ' ' || ev.key === 'Enter') && dispatcher({ type: T.CHANGE_TAB, payload: i })}
9293
role="button"
9394
tabIndex={0}
9495
id={`tab_${i}`}
@@ -102,6 +103,7 @@ const TabBar = ({ superState, dispatcher }) => {
102103
className="tab-act edit"
103104
onClick={editCur}
104105
type="button"
106+
aria-label="Edit workflow details"
105107
data-tip="Edit Workflow Details (Ctrl + Shift + E)"
106108
data-for="header-tab"
107109
>
@@ -112,6 +114,7 @@ const TabBar = ({ superState, dispatcher }) => {
112114
className="tab-act close"
113115
onClick={handleRequestCloseTab.bind(this, i)}
114116
type="button"
117+
aria-label="Close workflow tab"
115118
data-tip="Close current Workflow (Ctrl + Shift + L)"
116119
data-for="header-tab"
117120
>

src/component/ZoomSetter.jsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,21 @@ const ZoomComp = ({ superState, dispatcher }) => {
1919
<div
2020
role="button"
2121
tabIndex={0}
22+
aria-label="Reset zoom"
2223
className="zoom-box zoom-btn"
2324
onClick={() => myGraph.resetZoom()}
24-
onKeyDown={(ev) => ev.key === ' ' && (myGraph.resetZoom())}
25+
onKeyDown={(ev) => (ev.key === ' ' || ev.key === 'Enter') && myGraph.resetZoom()}
2526
>
2627
<BiReset />
2728

2829
</div>
2930
<div
3031
role="button"
3132
tabIndex={0}
33+
aria-label="Fit to screen"
3234
className="zoom-box zoom-btn"
3335
onClick={() => myGraph.fitZoom()}
34-
onKeyDown={(ev) => ev.key === ' ' && (myGraph.resetZoom())}
36+
onKeyDown={(ev) => (ev.key === ' ' || ev.key === 'Enter') && myGraph.fitZoom()}
3537
>
3638
<BiRectangle />
3739

0 commit comments

Comments
 (0)