Skip to content

Commit d5b5c70

Browse files
Update ambiguous label names; tooltip fixes (#528)
* Update label names so they are less ambiguous * Fix clickable tooltip tabIndex bug * Another tooltip fix
1 parent cb43a76 commit d5b5c70

File tree

7 files changed

+113
-20
lines changed

7 files changed

+113
-20
lines changed

lang/ui.en.json

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,10 @@
119119
"defaultMessage": "Connect",
120120
"description": "Connect action to connect to data collection micro:bit via Bluetooth or micro:bit radio"
121121
},
122+
"connect-action-aria": {
123+
"defaultMessage": "Connect to micro:bit",
124+
"description": "Connect action to connect to data collection micro:bit via Bluetooth or micro:bit radio"
125+
},
122126
"connect-battery-heading": {
123127
"defaultMessage": "Disconnect USB and connect battery pack",
124128
"description": "Battery connection dialog "
@@ -444,7 +448,7 @@
444448
"description": "Confirmation dialog text"
445449
},
446450
"delete-recording-aria": {
447-
"defaultMessage": "Delete recording",
451+
"defaultMessage": "Delete recording {sample} of {numSamples}",
448452
"description": "Aria label for data sample delete action"
449453
},
450454
"disconnect-action": {
@@ -1252,7 +1256,7 @@
12521256
"description": "Label for recording graph"
12531257
},
12541258
"recording-options-aria": {
1255-
"defaultMessage": "More recording options",
1259+
"defaultMessage": "More recording options for action \"{action}\"",
12561260
"description": "Aria label for more recording options button"
12571261
},
12581262
"reload-action": {
@@ -1312,7 +1316,11 @@
13121316
"description": "Notification after a hex file has been downloaded"
13131317
},
13141318
"select-icon-action-aria": {
1315-
"defaultMessage": "Pick icon",
1319+
"defaultMessage": "Pick icon for action \"{action}\"",
1320+
"description": "Aria label for pick icon button"
1321+
},
1322+
"select-icon-action-untitled-aria": {
1323+
"defaultMessage": "Pick icon for untitled action",
13161324
"description": "Aria label for pick icon button"
13171325
},
13181326
"select-icon-option-action-aria": {

src/components/ActionDataSamplesCard.tsx

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ const ActionDataSamplesCard = ({
5151
newRecordingId,
5252
clearNewRecordingId,
5353
}: ActionDataSamplesCardProps) => {
54+
const intl = useIntl();
5455
const deleteActionRecording = useStore((s) => s.deleteActionRecording);
5556
const view = useStore((s) => s.settings.dataSamplesView);
5657
if (view === DataSamplesView.GraphAndDataFeatures) {
@@ -76,6 +77,15 @@ const ActionDataSamplesCard = ({
7677
key={recording.ID}
7778
>
7879
<CloseButton
80+
aria-label={intl.formatMessage(
81+
{
82+
id: "delete-recording-aria",
83+
},
84+
{
85+
sample: value.recordings.length - idx,
86+
numSamples: value.recordings.length,
87+
}
88+
)}
7989
position="absolute"
8090
top={-2}
8191
right={-2}
@@ -88,6 +98,7 @@ const ActionDataSamplesCard = ({
8898
/>
8999
<DataSample
90100
recording={recording}
101+
numRecordings={value.recordings.length}
91102
actionId={value.ID}
92103
recordingIndex={idx}
93104
isNew={newRecordingId === recording.ID}
@@ -124,6 +135,7 @@ const ActionDataSamplesCard = ({
124135
actionId={value.ID}
125136
recordingIndex={idx}
126137
recording={recording}
138+
numRecordings={value.recordings.length}
127139
isNew={newRecordingId === recording.ID}
128140
onDelete={deleteActionRecording}
129141
onNewAnimationEnd={clearNewRecordingId}
@@ -199,7 +211,10 @@ const RecordingArea = ({
199211
<MoreMenuButton
200212
minW={8}
201213
variant={selected ? "record" : "recordOutline"}
202-
aria-label={intl.formatMessage({ id: "recording-options-aria" })}
214+
aria-label={intl.formatMessage(
215+
{ id: "recording-options-aria" },
216+
{ action: action.name }
217+
)}
203218
/>
204219
<Portal>
205220
<MenuList>
@@ -271,6 +286,7 @@ const RecordingArea = ({
271286

272287
const DataSample = ({
273288
recording,
289+
numRecordings,
274290
actionId,
275291
recordingIndex,
276292
isNew,
@@ -280,6 +296,7 @@ const DataSample = ({
280296
hasClose = true,
281297
}: {
282298
recording: RecordingData;
299+
numRecordings: number;
283300
actionId: number;
284301
recordingIndex: number;
285302
isNew: boolean;
@@ -307,9 +324,15 @@ const DataSample = ({
307324
right={0}
308325
zIndex={1}
309326
size="sm"
310-
aria-label={intl.formatMessage({
311-
id: "delete-recording-aria",
312-
})}
327+
aria-label={intl.formatMessage(
328+
{
329+
id: "delete-recording-aria",
330+
},
331+
{
332+
sample: numRecordings - recordingIndex,
333+
numSamples: numRecordings,
334+
}
335+
)}
313336
onClick={handleDelete}
314337
/>
315338
)}

src/components/ActionNameCard.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,12 @@ const ActionNameCard = ({
121121
) : (
122122
<LedIconSvg icon={icon} />
123123
)}
124-
{!readOnly && <LedIconPicker onIconSelected={handleIconSelected} />}
124+
{!readOnly && (
125+
<LedIconPicker
126+
actionName={value.name}
127+
onIconSelected={handleIconSelected}
128+
/>
129+
)}
125130
</HStack>
126131
<Input
127132
autoFocus={localName.length === 0}

src/components/ClickableTooltip.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,12 @@ const ClickableTooltip = ({
1818
const label = useDisclosure();
1919
const ref = useRef<HTMLDivElement>(null);
2020
const handleMouseEnter = useCallback(() => {
21-
const openTooltips = document.querySelectorAll(
22-
'[role="tooltip"]:not([hidden])'
21+
const focussedTooltips = Array.from(
22+
document.querySelectorAll(".focusable-tooltip")
2323
);
24-
if (!openTooltips.length) {
24+
if (
25+
focussedTooltips.every((tooltip) => tooltip !== document.activeElement)
26+
) {
2527
label.onOpen();
2628
}
2729
}, [label]);
@@ -44,12 +46,13 @@ const ClickableTooltip = ({
4446
return (
4547
<Tooltip isOpen={label.isOpen} {...rest} closeOnEsc={true}>
4648
<Flex
49+
className={isFocusable ? "focusable-tooltip" : undefined}
4750
onKeyDown={handleKeydown}
4851
ref={ref}
4952
onMouseEnter={handleMouseEnter}
5053
onMouseLeave={handleMouseLeave}
5154
onClick={label.onOpen}
52-
tabIndex={isDisabled ? undefined : 0}
55+
tabIndex={isFocusable && !isDisabled ? 0 : undefined}
5356
onFocus={isFocusable ? label.onOpen : undefined}
5457
onBlur={isFocusable ? label.onClose : undefined}
5558
_focusVisible={{

src/components/LedIconPicker.tsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,11 @@ import { MakeCodeIcon, makecodeIcons } from "../utils/icons";
1414
import LedIconSvg from "./icons/LedIconSvg";
1515

1616
interface LedIconPicker {
17+
actionName: string;
1718
onIconSelected: (icon: MakeCodeIcon) => void;
1819
}
1920

20-
const LedIconPicker = ({ onIconSelected }: LedIconPicker) => {
21+
const LedIconPicker = ({ actionName, onIconSelected }: LedIconPicker) => {
2122
const intl = useIntl();
2223
const handleClick = useCallback(
2324
(icon: MakeCodeIcon, callback: () => void) => {
@@ -35,7 +36,16 @@ const LedIconPicker = ({ onIconSelected }: LedIconPicker) => {
3536
<IconButton
3637
variant="ghost"
3738
color="blackAlpha.700"
38-
aria-label={intl.formatMessage({ id: "select-icon-action-aria" })}
39+
aria-label={
40+
actionName
41+
? intl.formatMessage(
42+
{ id: "select-icon-action-aria" },
43+
{ action: actionName }
44+
)
45+
: intl.formatMessage({
46+
id: "select-icon-action-untitled-aria",
47+
})
48+
}
3949
size="sm"
4050
>
4151
<RiArrowDropDownFill size={32} />

src/components/LiveGraphPanel.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
VStack,
1010
} from "@chakra-ui/react";
1111
import { useCallback, useRef } from "react";
12-
import { FormattedMessage } from "react-intl";
12+
import { FormattedMessage, useIntl } from "react-intl";
1313
import { ConnectionStatus } from "../connect-status-hooks";
1414
import { useConnectionStage } from "../connection-stage-hooks";
1515
import microbitImage from "../images/stylised-microbit-black.svg";
@@ -64,7 +64,7 @@ const LiveGraphPanel = ({
6464
});
6565
void actions.disconnect();
6666
}, [actions, logging]);
67-
67+
const intl = useIntl();
6868
return (
6969
<HStack
7070
position="relative"
@@ -92,7 +92,11 @@ const LiveGraphPanel = ({
9292
<Text>
9393
<FormattedMessage id={disconnectedTextId} />
9494
</Text>
95-
<Button variant="primary" onClick={handleConnectOrReconnect}>
95+
<Button
96+
variant="primary"
97+
onClick={handleConnectOrReconnect}
98+
aria-label={intl.formatMessage({ id: "connect-action-aria" })}
99+
>
96100
<FormattedMessage id="connect-action" />
97101
</Button>
98102
</VStack>

src/messages/ui.en.json

Lines changed: 43 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,12 @@
221221
"value": "Connect"
222222
}
223223
],
224+
"connect-action-aria": [
225+
{
226+
"type": 0,
227+
"value": "Connect to micro:bit"
228+
}
229+
],
224230
"connect-battery-heading": [
225231
{
226232
"type": 0,
@@ -758,7 +764,19 @@
758764
"delete-recording-aria": [
759765
{
760766
"type": 0,
761-
"value": "Delete recording"
767+
"value": "Delete recording "
768+
},
769+
{
770+
"type": 1,
771+
"value": "sample"
772+
},
773+
{
774+
"type": 0,
775+
"value": " of "
776+
},
777+
{
778+
"type": 1,
779+
"value": "numSamples"
762780
}
763781
],
764782
"disconnect-action": [
@@ -2204,7 +2222,15 @@
22042222
"recording-options-aria": [
22052223
{
22062224
"type": 0,
2207-
"value": "More recording options"
2225+
"value": "More recording options for action \""
2226+
},
2227+
{
2228+
"type": 1,
2229+
"value": "action"
2230+
},
2231+
{
2232+
"type": 0,
2233+
"value": "\""
22082234
}
22092235
],
22102236
"reload-action": [
@@ -2302,7 +2328,21 @@
23022328
"select-icon-action-aria": [
23032329
{
23042330
"type": 0,
2305-
"value": "Pick icon"
2331+
"value": "Pick icon for action \""
2332+
},
2333+
{
2334+
"type": 1,
2335+
"value": "action"
2336+
},
2337+
{
2338+
"type": 0,
2339+
"value": "\""
2340+
}
2341+
],
2342+
"select-icon-action-untitled-aria": [
2343+
{
2344+
"type": 0,
2345+
"value": "Pick icon for untitled action"
23062346
}
23072347
],
23082348
"select-icon-option-action-aria": [

0 commit comments

Comments
 (0)