@thecb/components 11.0.1 → 11.0.2-beta.1

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thecb/components",
3
- "version": "11.0.1",
3
+ "version": "11.0.2-beta.1",
4
4
  "description": "Common lib for CityBase react components",
5
5
  "main": "dist/index.cjs.js",
6
6
  "typings": "dist/index.d.ts",
Binary file
@@ -9,6 +9,7 @@ export interface ExternalLinkProps {
9
9
  weight?: string;
10
10
  extraStyles?: string;
11
11
  variant?: string;
12
+ containerTabIndex?: string;
12
13
  tabIndex?: string;
13
14
  dataQa?: string;
14
15
  ariaLabel?: string;
@@ -5,6 +5,7 @@ import { createThemeValues } from "../../../util/themeUtils";
5
5
  import { StyledExternalLink } from "./ExternalLink.styled";
6
6
  import { FONT_WEIGHT_REGULAR } from "../../../constants/style_constants";
7
7
  import { safeChildren } from "../../../util/general";
8
+ import { Box } from "../layouts";
8
9
 
9
10
  const ExternalLink = forwardRef(
10
11
  (
@@ -16,6 +17,7 @@ const ExternalLink = forwardRef(
16
17
  weight = FONT_WEIGHT_REGULAR,
17
18
  extraStyles = ``,
18
19
  variant = "primary",
20
+ containerTabIndex = "-1",
19
21
  tabIndex = "0",
20
22
  dataQa,
21
23
  ariaLabel,
@@ -30,27 +32,39 @@ const ExternalLink = forwardRef(
30
32
  "Link",
31
33
  variant
32
34
  );
35
+ const handleKeyDown = event => {
36
+ // This is to address an issue on Safari where the link's tab order and Enter key were not being recognized
37
+ if (event.key === "Enter" || event.keyCode === 13) {
38
+ if (newTab) {
39
+ window.open(href, "_blank");
40
+ } else {
41
+ window.location.href = href;
42
+ }
43
+ }
44
+ };
33
45
 
34
46
  return (
35
- <StyledExternalLink
36
- href={href}
37
- target={newTab ? "_blank" : ""}
38
- color={themeValues.externalLinkColor}
39
- size={size}
40
- lineheight={lineHeight}
41
- weight={weight}
42
- hovercolor={themeValues.hoverColor}
43
- activeColor={themeValues.activeColor}
44
- fontFamily={themeValues.fontFamily}
45
- tabIndex={tabIndex}
46
- extrastyles={extraStyles}
47
- rel={newTab ? "noopener" : ""}
48
- data-qa={dataQa}
49
- aria-label={ariaLabel}
50
- ref={ref}
51
- >
52
- {safeChildren(children, <span />)}
53
- </StyledExternalLink>
47
+ <Box padding="0" tabIndex={containerTabIndex} onKeyDown={handleKeyDown}>
48
+ <StyledExternalLink
49
+ href={href}
50
+ target={newTab ? "_blank" : ""}
51
+ color={themeValues.externalLinkColor}
52
+ size={size}
53
+ lineheight={lineHeight}
54
+ weight={weight}
55
+ hovercolor={themeValues.hoverColor}
56
+ activeColor={themeValues.activeColor}
57
+ fontFamily={themeValues.fontFamily}
58
+ tabIndex={tabIndex}
59
+ extrastyles={extraStyles}
60
+ rel={newTab ? "noopener" : ""}
61
+ data-qa={dataQa}
62
+ aria-label={ariaLabel}
63
+ ref={ref}
64
+ >
65
+ {safeChildren(children, <span />)}
66
+ </StyledExternalLink>
67
+ </Box>
54
68
  );
55
69
  }
56
70
  );
@@ -20,6 +20,7 @@ const meta = {
20
20
  fontWeight: undefined,
21
21
  fontSize: undefined,
22
22
  margin: undefined,
23
+ containerTabIndex: undefined,
23
24
  tabIndex: undefined,
24
25
  extraStyles: undefined,
25
26
  dataQa: undefined,
@@ -100,6 +101,13 @@ const meta = {
100
101
  defaultValue: { summary: undefined }
101
102
  }
102
103
  },
104
+ containerTabIndex: {
105
+ description: "Override for tab index value for link's container",
106
+ table: {
107
+ type: { summary: "string" },
108
+ defaultValue: { summary: undefined }
109
+ }
110
+ },
103
111
  tabIndex: {
104
112
  description: "Override for tab index value for link",
105
113
  table: {
@@ -206,6 +206,7 @@ const Modal = ({
206
206
  ) : (
207
207
  <Box padding="0.5rem">
208
208
  <ButtonWithAction
209
+ tabIndex="0"
209
210
  action={hideModal}
210
211
  variant="primary"
211
212
  text={closeButtonText}