Skip to content

Commit

Permalink
Fixing a11y voiceover issues
Browse files Browse the repository at this point in the history
  • Loading branch information
olliecurtis committed Jun 3, 2024
1 parent 65cfb0d commit 9de3f0a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 24 deletions.
33 changes: 11 additions & 22 deletions examples/bpk-component-tooltip/examples.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,7 @@
* limitations under the License.
*/

import { useRef, forwardRef } from 'react';

import {
colorMonteverde,
} from '@skyscanner/bpk-foundations-web/tokens/base.es6';
import { useRef } from 'react';

import BpkText, { TEXT_STYLES } from '../../packages/bpk-component-text';
import BpkTooltip, {
Expand All @@ -39,11 +35,6 @@ const Heading = withDefaultProps(BpkText, {
tagName: 'h4',
});

const HeadingComponent = forwardRef<HTMLDivElement, {children: Node | string}>((props, ref) => (
<div ref={ref}>
<Heading>{props.children}</Heading>
</div>
));

const DefaultExample = () => {
const target = useRef(null);
Expand All @@ -53,7 +44,7 @@ const DefaultExample = () => {
<BpkTooltip
ariaLabel="Montréal-Trudeau International Airport"
id="my-tooltip"
target={<HeadingComponent ref={target}>YUL</HeadingComponent>}
target={<Heading ref={target}>YUL</Heading>}
>
Montréal-Trudeau International Airport
</BpkTooltip>
Expand All @@ -70,7 +61,7 @@ const DarkExample = () => {
ariaLabel="Edinburgh Airport"
type={TOOLTIP_TYPES.dark}
id="my-tooltip"
target={<HeadingComponent ref={target}>EDI</HeadingComponent>}
target={<Heading ref={target}>EDI</Heading>}
>
Edinburgh Airport
</BpkTooltip>
Expand All @@ -86,7 +77,7 @@ const SideExample = () => {
<BpkTooltip
ariaLabel="Julius Nyerere International Airport, Dar es Salaam"
id="my-tooltip"
target={<HeadingComponent ref={target}>DAR</HeadingComponent>}
target={<Heading ref={target}>DAR</Heading>}
placement="right"
>
Julius Nyerere International Airport, Dar es Salaam
Expand All @@ -103,13 +94,12 @@ const NoPaddingExample = () => {
<BpkTooltip
ariaLabel="Singapore Changi Airport"
id="my-tooltip"
target={<HeadingComponent ref={target}>SIN</HeadingComponent>}
target={<Heading ref={target}>SIN</Heading>}
padded={false}
>
<div
style={{
borderBottomWidth: '5px',
borderBottomColor: colorMonteverde,
borderBottomStyle: 'solid',
padding: '.25rem',
}}
Expand Down Expand Up @@ -157,21 +147,21 @@ const FocusExample = () => {
<BpkTooltip
ariaLabel="Should be focused on first"
id="my-tooltip"
target={<HeadingComponent ref={targetRef1}>One</HeadingComponent>}
target={<Heading ref={targetRef1}>One</Heading>}
>
Should be focused on first
</BpkTooltip>
<BpkTooltip
ariaLabel="Should be focused on second"
id="my-tooltip"
target={<HeadingComponent ref={targetRef2}>Two</HeadingComponent>}
target={<Heading ref={targetRef2}>Two</Heading>}
>
Should be focused on second
</BpkTooltip>
<BpkTooltip
ariaLabel="Should be focused on third"
id="my-tooltip"
target={<HeadingComponent ref={targetRef3}>Three</HeadingComponent>}
target={<Heading ref={targetRef3}>Three</Heading>}
>
Should be focused on third
</BpkTooltip>
Expand All @@ -181,7 +171,7 @@ const FocusExample = () => {
<BpkTooltip
ariaLabel="Should be focused on fifth"
id="my-tooltip"
target={<HeadingComponent ref={targetRef5}>Five</HeadingComponent>}
target={<Heading ref={targetRef5}>Five</Heading>}
>
Should be focused on fifth
</BpkTooltip>
Expand All @@ -197,7 +187,7 @@ const VisualTestExample = () => {
<BpkTooltip
ariaLabel="Montréal-Trudeau International Airport"
id="my-tooltip"
target={<HeadingComponent ref={target}>YUL</HeadingComponent>}
target={<Heading ref={target}>YUL</Heading>}
isOpen
>
Montréal-Trudeau International Airport
Expand All @@ -206,13 +196,12 @@ const VisualTestExample = () => {
);
};


export {
DefaultExample,
DarkExample,
SideExample,
NoPaddingExample,
LinkExample,
FocusExample,
VisualTestExample
VisualTestExample,
};
1 change: 0 additions & 1 deletion packages/bpk-component-tooltip/src/BpkTooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,6 @@ const BpkTooltip = ({
tabIndex={-1}
role="dialog"
className={classNames}
aria-label={ariaLabel}
{...rest}
>
<FloatingArrow
Expand Down
1 change: 0 additions & 1 deletion packages/bpk-component-tooltip/src/accessibility-test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ describe('BpkTooltip accessibility tests', () => {
id="my-popover"
ariaLabel="Tooltip"
target={<p>My tooltip target</p>}
isOpen
>
My tooltip content
</BpkTooltip>,
Expand Down

0 comments on commit 9de3f0a

Please sign in to comment.