carbon-react 144.18.0 → 144.20.0
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/esm/components/action-popover/action-popover-menu-button/action-popover-menu-button.component.d.ts +3 -1
- package/esm/components/action-popover/action-popover-menu-button/action-popover-menu-button.component.js +2 -1
- package/esm/components/action-popover/action-popover.component.d.ts +7 -1
- package/esm/components/action-popover/action-popover.component.js +6 -0
- package/esm/components/advanced-color-picker/advanced-color-picker.component.d.ts +3 -2
- package/esm/components/advanced-color-picker/advanced-color-picker.component.js +3 -1
- package/esm/components/dialog/dialog.component.js +4 -1
- package/esm/components/dialog-full-screen/dialog-full-screen.component.d.ts +1 -1
- package/esm/components/dialog-full-screen/dialog-full-screen.component.js +3 -1
- package/esm/components/modal/modal.component.d.ts +5 -1
- package/esm/components/modal/modal.component.js +2 -1
- package/esm/components/sidebar/sidebar.component.d.ts +1 -1
- package/esm/components/sidebar/sidebar.component.js +4 -1
- package/esm/components/vertical-menu/vertical-menu-full-screen/vertical-menu-full-screen.component.js +2 -1
- package/lib/components/action-popover/action-popover-menu-button/action-popover-menu-button.component.d.ts +3 -1
- package/lib/components/action-popover/action-popover-menu-button/action-popover-menu-button.component.js +2 -1
- package/lib/components/action-popover/action-popover.component.d.ts +7 -1
- package/lib/components/action-popover/action-popover.component.js +6 -0
- package/lib/components/advanced-color-picker/advanced-color-picker.component.d.ts +3 -2
- package/lib/components/advanced-color-picker/advanced-color-picker.component.js +3 -1
- package/lib/components/dialog/dialog.component.js +4 -1
- package/lib/components/dialog-full-screen/dialog-full-screen.component.d.ts +1 -1
- package/lib/components/dialog-full-screen/dialog-full-screen.component.js +3 -1
- package/lib/components/modal/modal.component.d.ts +5 -1
- package/lib/components/modal/modal.component.js +2 -1
- package/lib/components/sidebar/sidebar.component.d.ts +1 -1
- package/lib/components/sidebar/sidebar.component.js +4 -1
- package/lib/components/vertical-menu/vertical-menu-full-screen/vertical-menu-full-screen.component.js +2 -1
- package/package.json +1 -1
|
@@ -4,6 +4,8 @@ import { IconType } from "../../icon";
|
|
|
4
4
|
export declare type ActionPopoverMenuButtonAria = {
|
|
5
5
|
"aria-haspopup": string;
|
|
6
6
|
"aria-label": string;
|
|
7
|
+
"aria-labelledby"?: string;
|
|
8
|
+
"aria-describedby"?: string;
|
|
7
9
|
"aria-controls": string;
|
|
8
10
|
"aria-expanded": string;
|
|
9
11
|
};
|
|
@@ -26,7 +28,7 @@ export interface ActionPopoverMenuButtonProps {
|
|
|
26
28
|
tabIndex: number;
|
|
27
29
|
}
|
|
28
30
|
export declare const ActionPopoverMenuButton: {
|
|
29
|
-
({ buttonType, iconType, iconPosition, size, children, ...props }: ActionPopoverMenuButtonProps): React.JSX.Element;
|
|
31
|
+
({ buttonType, iconType, iconPosition, size, children, ariaAttributes, ...props }: ActionPopoverMenuButtonProps): React.JSX.Element;
|
|
30
32
|
displayName: string;
|
|
31
33
|
};
|
|
32
34
|
export default ActionPopoverMenuButton;
|
|
@@ -9,12 +9,13 @@ export const ActionPopoverMenuButton = ({
|
|
|
9
9
|
iconPosition,
|
|
10
10
|
size,
|
|
11
11
|
children,
|
|
12
|
+
ariaAttributes,
|
|
12
13
|
...props
|
|
13
14
|
}) => /*#__PURE__*/React.createElement(MenuButtonOverrideWrapper, null, /*#__PURE__*/React.createElement(Button, _extends({
|
|
14
15
|
buttonType: buttonType,
|
|
15
16
|
iconType: iconType,
|
|
16
17
|
iconPosition: iconPosition,
|
|
17
18
|
size: size
|
|
18
|
-
}, props), children));
|
|
19
|
+
}, ariaAttributes, props), children));
|
|
19
20
|
ActionPopoverMenuButton.displayName = "ActionPopoverMenuButton";
|
|
20
21
|
export default ActionPopoverMenuButton;
|
|
@@ -7,6 +7,8 @@ export interface RenderButtonProps {
|
|
|
7
7
|
ariaAttributes: {
|
|
8
8
|
"aria-haspopup": string;
|
|
9
9
|
"aria-label": string;
|
|
10
|
+
"aria-labelledby"?: string;
|
|
11
|
+
"aria-describedby"?: string;
|
|
10
12
|
"aria-controls": string;
|
|
11
13
|
"aria-expanded": string;
|
|
12
14
|
};
|
|
@@ -32,6 +34,10 @@ export interface ActionPopoverProps extends MarginProps {
|
|
|
32
34
|
rightAlignMenu?: boolean;
|
|
33
35
|
/** Prop to specify an aria-label for the component */
|
|
34
36
|
"aria-label"?: string;
|
|
37
|
+
/** Prop to specify an aria-labelledby for the component */
|
|
38
|
+
"aria-labelledby"?: string;
|
|
39
|
+
/** Prop to specify an aria-describedby for the component */
|
|
40
|
+
"aria-describedby"?: string;
|
|
35
41
|
}
|
|
36
|
-
export declare const ActionPopover: ({ children, id, onOpen, onClose, rightAlignMenu, renderButton, placement, horizontalAlignment, submenuPosition, "aria-label": ariaLabel, ...rest }: ActionPopoverProps) => React.JSX.Element;
|
|
42
|
+
export declare const ActionPopover: ({ children, id, onOpen, onClose, rightAlignMenu, renderButton, placement, horizontalAlignment, submenuPosition, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, "aria-describedby": ariaDescribedBy, ...rest }: ActionPopoverProps) => React.JSX.Element;
|
|
37
43
|
export default ActionPopover;
|
|
@@ -26,6 +26,8 @@ export const ActionPopover = ({
|
|
|
26
26
|
horizontalAlignment = "left",
|
|
27
27
|
submenuPosition = "left",
|
|
28
28
|
"aria-label": ariaLabel,
|
|
29
|
+
"aria-labelledby": ariaLabelledBy,
|
|
30
|
+
"aria-describedby": ariaDescribedBy,
|
|
29
31
|
...rest
|
|
30
32
|
}) => {
|
|
31
33
|
const l = useLocale();
|
|
@@ -143,6 +145,8 @@ export const ActionPopover = ({
|
|
|
143
145
|
ariaAttributes: {
|
|
144
146
|
"aria-haspopup": "true",
|
|
145
147
|
"aria-label": ariaLabel || l.actionPopover.ariaLabel(),
|
|
148
|
+
"aria-labelledby": ariaLabelledBy,
|
|
149
|
+
"aria-describedby": ariaDescribedBy,
|
|
146
150
|
"aria-controls": menuID,
|
|
147
151
|
"aria-expanded": `${isOpen}`
|
|
148
152
|
}
|
|
@@ -152,6 +156,8 @@ export const ActionPopover = ({
|
|
|
152
156
|
role: "button",
|
|
153
157
|
"aria-haspopup": "true",
|
|
154
158
|
"aria-label": ariaLabel || l.actionPopover.ariaLabel(),
|
|
159
|
+
"aria-labelledby": ariaLabelledBy,
|
|
160
|
+
"aria-describedby": ariaDescribedBy,
|
|
155
161
|
"aria-controls": menuID,
|
|
156
162
|
"aria-expanded": isOpen,
|
|
157
163
|
tabIndex: isOpen ? -1 : 0,
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { MarginProps } from "styled-system";
|
|
3
|
+
import { ModalProps } from "../modal";
|
|
3
4
|
export interface AdvancedColor {
|
|
4
5
|
label: string;
|
|
5
6
|
value: string;
|
|
6
7
|
}
|
|
7
|
-
export interface AdvancedColorPickerProps extends MarginProps {
|
|
8
|
+
export interface AdvancedColorPickerProps extends MarginProps, Pick<ModalProps, "restoreFocusOnClose"> {
|
|
8
9
|
/** Prop to specify the aria-describedby property of the component */
|
|
9
10
|
"aria-describedby"?: string;
|
|
10
11
|
/**
|
|
@@ -39,5 +40,5 @@ export interface AdvancedColorPickerProps extends MarginProps {
|
|
|
39
40
|
/** Prop for `selectedColor` containing pre-selected color for `controlled` use */
|
|
40
41
|
selectedColor?: string;
|
|
41
42
|
}
|
|
42
|
-
export declare const AdvancedColorPicker: ({ "aria-describedby": ariaDescribedBy, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, availableColors, defaultColor, name, onOpen, onClose, onChange, onBlur, open, role, selectedColor, ...props }: AdvancedColorPickerProps) => React.JSX.Element;
|
|
43
|
+
export declare const AdvancedColorPicker: ({ "aria-describedby": ariaDescribedBy, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, availableColors, defaultColor, name, onOpen, onClose, onChange, onBlur, open, role, selectedColor, restoreFocusOnClose, ...props }: AdvancedColorPickerProps) => React.JSX.Element;
|
|
43
44
|
export default AdvancedColorPicker;
|
|
@@ -24,6 +24,7 @@ export const AdvancedColorPicker = ({
|
|
|
24
24
|
open = false,
|
|
25
25
|
role,
|
|
26
26
|
selectedColor,
|
|
27
|
+
restoreFocusOnClose = true,
|
|
27
28
|
...props
|
|
28
29
|
}) => {
|
|
29
30
|
const [dialogOpen, setDialogOpen] = useState();
|
|
@@ -142,7 +143,8 @@ export const AdvancedColorPicker = ({
|
|
|
142
143
|
onCancel: handleOnClose,
|
|
143
144
|
bespokeFocusTrap: handleFocus,
|
|
144
145
|
focusFirstElement: selectedColorRef,
|
|
145
|
-
role: role
|
|
146
|
+
role: role,
|
|
147
|
+
restoreFocusOnClose: restoreFocusOnClose
|
|
146
148
|
}, /*#__PURE__*/React.createElement(StyledAdvancedColorPickerPreview, {
|
|
147
149
|
"data-element": "color-picker-preview",
|
|
148
150
|
color: currentColor
|
|
@@ -40,6 +40,7 @@ const Dialog = /*#__PURE__*/forwardRef(({
|
|
|
40
40
|
focusableContainers,
|
|
41
41
|
topModalOverride,
|
|
42
42
|
closeButtonDataProps,
|
|
43
|
+
restoreFocusOnClose = true,
|
|
43
44
|
...rest
|
|
44
45
|
}, ref) => {
|
|
45
46
|
if (!deprecatedClassNameWarningShown && className) {
|
|
@@ -101,7 +102,8 @@ const Dialog = /*#__PURE__*/forwardRef(({
|
|
|
101
102
|
disableEscKey: disableEscKey,
|
|
102
103
|
disableClose: disableClose,
|
|
103
104
|
className: className ? `${className} carbon-dialog` : "carbon-dialog",
|
|
104
|
-
topModalOverride: topModalOverride
|
|
105
|
+
topModalOverride: topModalOverride,
|
|
106
|
+
restoreFocusOnClose: restoreFocusOnClose
|
|
105
107
|
}, /*#__PURE__*/React.createElement(FocusTrap, {
|
|
106
108
|
autoFocus: !disableAutoFocus,
|
|
107
109
|
focusFirstElement: focusFirstElement,
|
|
@@ -182,6 +184,7 @@ if (process.env.NODE_ENV !== "production") {
|
|
|
182
184
|
"help": PropTypes.string,
|
|
183
185
|
"onCancel": PropTypes.func,
|
|
184
186
|
"open": PropTypes.bool.isRequired,
|
|
187
|
+
"restoreFocusOnClose": PropTypes.bool,
|
|
185
188
|
"role": PropTypes.string,
|
|
186
189
|
"showCloseIcon": PropTypes.bool,
|
|
187
190
|
"size": PropTypes.oneOf(["auto", "extra-large", "extra-small", "large", "maximise", "medium-large", "medium-small", "medium", "small"]),
|
|
@@ -55,5 +55,5 @@ export interface DialogFullScreenProps extends ModalProps {
|
|
|
55
55
|
/** A custom close event handler */
|
|
56
56
|
onCancel?: (ev: React.KeyboardEvent<HTMLElement> | React.MouseEvent<HTMLButtonElement>) => void;
|
|
57
57
|
}
|
|
58
|
-
export declare const DialogFullScreen: ({ "aria-describedby": ariaDescribedBy, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, disableAutoFocus, focusFirstElement, bespokeFocusTrap, open, children, title, subtitle, pagesStyling, headerChildren, showCloseIcon, disableContentPadding, disableEscKey, onCancel, contentRef, help, role, focusableContainers, focusableSelectors, topModalOverride, closeButtonDataProps, ...rest }: DialogFullScreenProps) => React.JSX.Element;
|
|
58
|
+
export declare const DialogFullScreen: ({ "aria-describedby": ariaDescribedBy, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, disableAutoFocus, focusFirstElement, bespokeFocusTrap, open, children, title, subtitle, pagesStyling, headerChildren, showCloseIcon, disableContentPadding, disableEscKey, onCancel, contentRef, help, role, focusableContainers, focusableSelectors, topModalOverride, closeButtonDataProps, restoreFocusOnClose, ...rest }: DialogFullScreenProps) => React.JSX.Element;
|
|
59
59
|
export default DialogFullScreen;
|
|
@@ -37,6 +37,7 @@ export const DialogFullScreen = ({
|
|
|
37
37
|
focusableSelectors,
|
|
38
38
|
topModalOverride,
|
|
39
39
|
closeButtonDataProps,
|
|
40
|
+
restoreFocusOnClose = true,
|
|
40
41
|
...rest
|
|
41
42
|
}) => {
|
|
42
43
|
const locale = useLocale();
|
|
@@ -87,7 +88,8 @@ export const DialogFullScreen = ({
|
|
|
87
88
|
open: open,
|
|
88
89
|
onCancel: onCancel,
|
|
89
90
|
disableEscKey: disableEscKey,
|
|
90
|
-
topModalOverride: topModalOverride
|
|
91
|
+
topModalOverride: topModalOverride,
|
|
92
|
+
restoreFocusOnClose: restoreFocusOnClose
|
|
91
93
|
}, componentTags), /*#__PURE__*/React.createElement(FocusTrap, {
|
|
92
94
|
autoFocus: !disableAutoFocus,
|
|
93
95
|
focusFirstElement: focusFirstElement,
|
|
@@ -21,6 +21,10 @@ export interface ModalProps extends Omit<TagProps, "data-component"> {
|
|
|
21
21
|
timeout?: number;
|
|
22
22
|
/** Manually override the internal modal stacking order to set this as top */
|
|
23
23
|
topModalOverride?: boolean;
|
|
24
|
+
/** Enables the automatic restoration of focus to the element that invoked
|
|
25
|
+
* the modal when the modal is closed.
|
|
26
|
+
*/
|
|
27
|
+
restoreFocusOnClose?: boolean;
|
|
24
28
|
}
|
|
25
|
-
declare const Modal: ({ children, "data-element": dataElement, "data-role": dataRole, open, onCancel, disableEscKey, disableClose, enableBackgroundUI, timeout, topModalOverride, ...rest }: ModalProps) => React.JSX.Element;
|
|
29
|
+
declare const Modal: ({ children, "data-element": dataElement, "data-role": dataRole, open, onCancel, disableEscKey, disableClose, enableBackgroundUI, timeout, topModalOverride, restoreFocusOnClose, ...rest }: ModalProps) => React.JSX.Element;
|
|
26
30
|
export default Modal;
|
|
@@ -21,6 +21,7 @@ const Modal = ({
|
|
|
21
21
|
enableBackgroundUI = false,
|
|
22
22
|
timeout = 300,
|
|
23
23
|
topModalOverride,
|
|
24
|
+
restoreFocusOnClose = true,
|
|
24
25
|
...rest
|
|
25
26
|
}) => {
|
|
26
27
|
if (!deprecatedClassNameWarningShown && rest.className) {
|
|
@@ -65,7 +66,7 @@ const Modal = ({
|
|
|
65
66
|
modalRef: ref,
|
|
66
67
|
setTriggerRefocusFlag,
|
|
67
68
|
topModalOverride,
|
|
68
|
-
focusCallToActionElement: document.activeElement
|
|
69
|
+
focusCallToActionElement: restoreFocusOnClose ? document.activeElement : undefined
|
|
69
70
|
});
|
|
70
71
|
let background;
|
|
71
72
|
let content;
|
|
@@ -5,7 +5,7 @@ import { TagProps } from "../../__internal__/utils/helpers/tags/tags";
|
|
|
5
5
|
declare type CustomRefObject<T> = {
|
|
6
6
|
current?: T | null;
|
|
7
7
|
};
|
|
8
|
-
export interface SidebarProps extends PaddingProps, Omit<TagProps, "data-component">, WidthProps, Pick<ModalProps, "topModalOverride"> {
|
|
8
|
+
export interface SidebarProps extends PaddingProps, Omit<TagProps, "data-component">, WidthProps, Pick<ModalProps, "topModalOverride" | "restoreFocusOnClose"> {
|
|
9
9
|
/** Prop to specify the aria-describedby property of the component */
|
|
10
10
|
"aria-describedby"?: string;
|
|
11
11
|
/**
|
|
@@ -38,6 +38,7 @@ const Sidebar = /*#__PURE__*/React.forwardRef(({
|
|
|
38
38
|
width,
|
|
39
39
|
headerPadding = {},
|
|
40
40
|
topModalOverride,
|
|
41
|
+
restoreFocusOnClose = true,
|
|
41
42
|
...rest
|
|
42
43
|
}, ref) => {
|
|
43
44
|
const locale = useLocale();
|
|
@@ -93,7 +94,8 @@ const Sidebar = /*#__PURE__*/React.forwardRef(({
|
|
|
93
94
|
onCancel: onCancel,
|
|
94
95
|
disableEscKey: disableEscKey,
|
|
95
96
|
enableBackgroundUI: enableBackgroundUI,
|
|
96
|
-
topModalOverride: topModalOverride
|
|
97
|
+
topModalOverride: topModalOverride,
|
|
98
|
+
restoreFocusOnClose: restoreFocusOnClose
|
|
97
99
|
}, enableBackgroundUI ? sidebar : /*#__PURE__*/React.createElement(FocusTrap, {
|
|
98
100
|
wrapperRef: sidebarRef,
|
|
99
101
|
isOpen: open,
|
|
@@ -449,6 +451,7 @@ if (process.env.NODE_ENV !== "production") {
|
|
|
449
451
|
"toString": PropTypes.func.isRequired,
|
|
450
452
|
"valueOf": PropTypes.func.isRequired
|
|
451
453
|
}), PropTypes.string]),
|
|
454
|
+
"restoreFocusOnClose": PropTypes.bool,
|
|
452
455
|
"role": PropTypes.string,
|
|
453
456
|
"size": PropTypes.oneOf(["extra-large", "extra-small", "large", "medium-large", "medium-small", "medium", "small"]),
|
|
454
457
|
"topModalOverride": PropTypes.bool,
|
|
@@ -32,7 +32,8 @@ export const VerticalMenuFullScreen = ({
|
|
|
32
32
|
open: isOpen,
|
|
33
33
|
closeModal: handleKeyDown,
|
|
34
34
|
modalRef: menuWrapperRef,
|
|
35
|
-
topModalOverride: true
|
|
35
|
+
topModalOverride: true,
|
|
36
|
+
focusCallToActionElement: document.activeElement
|
|
36
37
|
});
|
|
37
38
|
|
|
38
39
|
// TODO remove this as part of FE-5650
|
|
@@ -4,6 +4,8 @@ import { IconType } from "../../icon";
|
|
|
4
4
|
export declare type ActionPopoverMenuButtonAria = {
|
|
5
5
|
"aria-haspopup": string;
|
|
6
6
|
"aria-label": string;
|
|
7
|
+
"aria-labelledby"?: string;
|
|
8
|
+
"aria-describedby"?: string;
|
|
7
9
|
"aria-controls": string;
|
|
8
10
|
"aria-expanded": string;
|
|
9
11
|
};
|
|
@@ -26,7 +28,7 @@ export interface ActionPopoverMenuButtonProps {
|
|
|
26
28
|
tabIndex: number;
|
|
27
29
|
}
|
|
28
30
|
export declare const ActionPopoverMenuButton: {
|
|
29
|
-
({ buttonType, iconType, iconPosition, size, children, ...props }: ActionPopoverMenuButtonProps): React.JSX.Element;
|
|
31
|
+
({ buttonType, iconType, iconPosition, size, children, ariaAttributes, ...props }: ActionPopoverMenuButtonProps): React.JSX.Element;
|
|
30
32
|
displayName: string;
|
|
31
33
|
};
|
|
32
34
|
export default ActionPopoverMenuButton;
|
|
@@ -16,13 +16,14 @@ const ActionPopoverMenuButton = ({
|
|
|
16
16
|
iconPosition,
|
|
17
17
|
size,
|
|
18
18
|
children,
|
|
19
|
+
ariaAttributes,
|
|
19
20
|
...props
|
|
20
21
|
}) => /*#__PURE__*/_react.default.createElement(_actionPopover.MenuButtonOverrideWrapper, null, /*#__PURE__*/_react.default.createElement(_button.default, _extends({
|
|
21
22
|
buttonType: buttonType,
|
|
22
23
|
iconType: iconType,
|
|
23
24
|
iconPosition: iconPosition,
|
|
24
25
|
size: size
|
|
25
|
-
}, props), children));
|
|
26
|
+
}, ariaAttributes, props), children));
|
|
26
27
|
exports.ActionPopoverMenuButton = ActionPopoverMenuButton;
|
|
27
28
|
ActionPopoverMenuButton.displayName = "ActionPopoverMenuButton";
|
|
28
29
|
var _default = exports.default = ActionPopoverMenuButton;
|
|
@@ -7,6 +7,8 @@ export interface RenderButtonProps {
|
|
|
7
7
|
ariaAttributes: {
|
|
8
8
|
"aria-haspopup": string;
|
|
9
9
|
"aria-label": string;
|
|
10
|
+
"aria-labelledby"?: string;
|
|
11
|
+
"aria-describedby"?: string;
|
|
10
12
|
"aria-controls": string;
|
|
11
13
|
"aria-expanded": string;
|
|
12
14
|
};
|
|
@@ -32,6 +34,10 @@ export interface ActionPopoverProps extends MarginProps {
|
|
|
32
34
|
rightAlignMenu?: boolean;
|
|
33
35
|
/** Prop to specify an aria-label for the component */
|
|
34
36
|
"aria-label"?: string;
|
|
37
|
+
/** Prop to specify an aria-labelledby for the component */
|
|
38
|
+
"aria-labelledby"?: string;
|
|
39
|
+
/** Prop to specify an aria-describedby for the component */
|
|
40
|
+
"aria-describedby"?: string;
|
|
35
41
|
}
|
|
36
|
-
export declare const ActionPopover: ({ children, id, onOpen, onClose, rightAlignMenu, renderButton, placement, horizontalAlignment, submenuPosition, "aria-label": ariaLabel, ...rest }: ActionPopoverProps) => React.JSX.Element;
|
|
42
|
+
export declare const ActionPopover: ({ children, id, onOpen, onClose, rightAlignMenu, renderButton, placement, horizontalAlignment, submenuPosition, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, "aria-describedby": ariaDescribedBy, ...rest }: ActionPopoverProps) => React.JSX.Element;
|
|
37
43
|
export default ActionPopover;
|
|
@@ -35,6 +35,8 @@ const ActionPopover = ({
|
|
|
35
35
|
horizontalAlignment = "left",
|
|
36
36
|
submenuPosition = "left",
|
|
37
37
|
"aria-label": ariaLabel,
|
|
38
|
+
"aria-labelledby": ariaLabelledBy,
|
|
39
|
+
"aria-describedby": ariaDescribedBy,
|
|
38
40
|
...rest
|
|
39
41
|
}) => {
|
|
40
42
|
const l = (0, _useLocale.default)();
|
|
@@ -152,6 +154,8 @@ const ActionPopover = ({
|
|
|
152
154
|
ariaAttributes: {
|
|
153
155
|
"aria-haspopup": "true",
|
|
154
156
|
"aria-label": ariaLabel || l.actionPopover.ariaLabel(),
|
|
157
|
+
"aria-labelledby": ariaLabelledBy,
|
|
158
|
+
"aria-describedby": ariaDescribedBy,
|
|
155
159
|
"aria-controls": menuID,
|
|
156
160
|
"aria-expanded": `${isOpen}`
|
|
157
161
|
}
|
|
@@ -161,6 +165,8 @@ const ActionPopover = ({
|
|
|
161
165
|
role: "button",
|
|
162
166
|
"aria-haspopup": "true",
|
|
163
167
|
"aria-label": ariaLabel || l.actionPopover.ariaLabel(),
|
|
168
|
+
"aria-labelledby": ariaLabelledBy,
|
|
169
|
+
"aria-describedby": ariaDescribedBy,
|
|
164
170
|
"aria-controls": menuID,
|
|
165
171
|
"aria-expanded": isOpen,
|
|
166
172
|
tabIndex: isOpen ? -1 : 0,
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { MarginProps } from "styled-system";
|
|
3
|
+
import { ModalProps } from "../modal";
|
|
3
4
|
export interface AdvancedColor {
|
|
4
5
|
label: string;
|
|
5
6
|
value: string;
|
|
6
7
|
}
|
|
7
|
-
export interface AdvancedColorPickerProps extends MarginProps {
|
|
8
|
+
export interface AdvancedColorPickerProps extends MarginProps, Pick<ModalProps, "restoreFocusOnClose"> {
|
|
8
9
|
/** Prop to specify the aria-describedby property of the component */
|
|
9
10
|
"aria-describedby"?: string;
|
|
10
11
|
/**
|
|
@@ -39,5 +40,5 @@ export interface AdvancedColorPickerProps extends MarginProps {
|
|
|
39
40
|
/** Prop for `selectedColor` containing pre-selected color for `controlled` use */
|
|
40
41
|
selectedColor?: string;
|
|
41
42
|
}
|
|
42
|
-
export declare const AdvancedColorPicker: ({ "aria-describedby": ariaDescribedBy, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, availableColors, defaultColor, name, onOpen, onClose, onChange, onBlur, open, role, selectedColor, ...props }: AdvancedColorPickerProps) => React.JSX.Element;
|
|
43
|
+
export declare const AdvancedColorPicker: ({ "aria-describedby": ariaDescribedBy, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, availableColors, defaultColor, name, onOpen, onClose, onChange, onBlur, open, role, selectedColor, restoreFocusOnClose, ...props }: AdvancedColorPickerProps) => React.JSX.Element;
|
|
43
44
|
export default AdvancedColorPicker;
|
|
@@ -33,6 +33,7 @@ const AdvancedColorPicker = ({
|
|
|
33
33
|
open = false,
|
|
34
34
|
role,
|
|
35
35
|
selectedColor,
|
|
36
|
+
restoreFocusOnClose = true,
|
|
36
37
|
...props
|
|
37
38
|
}) => {
|
|
38
39
|
const [dialogOpen, setDialogOpen] = (0, _react.useState)();
|
|
@@ -151,7 +152,8 @@ const AdvancedColorPicker = ({
|
|
|
151
152
|
onCancel: handleOnClose,
|
|
152
153
|
bespokeFocusTrap: handleFocus,
|
|
153
154
|
focusFirstElement: selectedColorRef,
|
|
154
|
-
role: role
|
|
155
|
+
role: role,
|
|
156
|
+
restoreFocusOnClose: restoreFocusOnClose
|
|
155
157
|
}, /*#__PURE__*/_react.default.createElement(_advancedColorPicker.StyledAdvancedColorPickerPreview, {
|
|
156
158
|
"data-element": "color-picker-preview",
|
|
157
159
|
color: currentColor
|
|
@@ -49,6 +49,7 @@ const Dialog = exports.Dialog = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
|
49
49
|
focusableContainers,
|
|
50
50
|
topModalOverride,
|
|
51
51
|
closeButtonDataProps,
|
|
52
|
+
restoreFocusOnClose = true,
|
|
52
53
|
...rest
|
|
53
54
|
}, ref) => {
|
|
54
55
|
if (!deprecatedClassNameWarningShown && className) {
|
|
@@ -110,7 +111,8 @@ const Dialog = exports.Dialog = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
|
110
111
|
disableEscKey: disableEscKey,
|
|
111
112
|
disableClose: disableClose,
|
|
112
113
|
className: className ? `${className} carbon-dialog` : "carbon-dialog",
|
|
113
|
-
topModalOverride: topModalOverride
|
|
114
|
+
topModalOverride: topModalOverride,
|
|
115
|
+
restoreFocusOnClose: restoreFocusOnClose
|
|
114
116
|
}, /*#__PURE__*/_react.default.createElement(_focusTrap.default, {
|
|
115
117
|
autoFocus: !disableAutoFocus,
|
|
116
118
|
focusFirstElement: focusFirstElement,
|
|
@@ -191,6 +193,7 @@ if (process.env.NODE_ENV !== "production") {
|
|
|
191
193
|
"help": _propTypes.default.string,
|
|
192
194
|
"onCancel": _propTypes.default.func,
|
|
193
195
|
"open": _propTypes.default.bool.isRequired,
|
|
196
|
+
"restoreFocusOnClose": _propTypes.default.bool,
|
|
194
197
|
"role": _propTypes.default.string,
|
|
195
198
|
"showCloseIcon": _propTypes.default.bool,
|
|
196
199
|
"size": _propTypes.default.oneOf(["auto", "extra-large", "extra-small", "large", "maximise", "medium-large", "medium-small", "medium", "small"]),
|
|
@@ -55,5 +55,5 @@ export interface DialogFullScreenProps extends ModalProps {
|
|
|
55
55
|
/** A custom close event handler */
|
|
56
56
|
onCancel?: (ev: React.KeyboardEvent<HTMLElement> | React.MouseEvent<HTMLButtonElement>) => void;
|
|
57
57
|
}
|
|
58
|
-
export declare const DialogFullScreen: ({ "aria-describedby": ariaDescribedBy, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, disableAutoFocus, focusFirstElement, bespokeFocusTrap, open, children, title, subtitle, pagesStyling, headerChildren, showCloseIcon, disableContentPadding, disableEscKey, onCancel, contentRef, help, role, focusableContainers, focusableSelectors, topModalOverride, closeButtonDataProps, ...rest }: DialogFullScreenProps) => React.JSX.Element;
|
|
58
|
+
export declare const DialogFullScreen: ({ "aria-describedby": ariaDescribedBy, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, disableAutoFocus, focusFirstElement, bespokeFocusTrap, open, children, title, subtitle, pagesStyling, headerChildren, showCloseIcon, disableContentPadding, disableEscKey, onCancel, contentRef, help, role, focusableContainers, focusableSelectors, topModalOverride, closeButtonDataProps, restoreFocusOnClose, ...rest }: DialogFullScreenProps) => React.JSX.Element;
|
|
59
59
|
export default DialogFullScreen;
|
|
@@ -46,6 +46,7 @@ const DialogFullScreen = ({
|
|
|
46
46
|
focusableSelectors,
|
|
47
47
|
topModalOverride,
|
|
48
48
|
closeButtonDataProps,
|
|
49
|
+
restoreFocusOnClose = true,
|
|
49
50
|
...rest
|
|
50
51
|
}) => {
|
|
51
52
|
const locale = (0, _useLocale.default)();
|
|
@@ -96,7 +97,8 @@ const DialogFullScreen = ({
|
|
|
96
97
|
open: open,
|
|
97
98
|
onCancel: onCancel,
|
|
98
99
|
disableEscKey: disableEscKey,
|
|
99
|
-
topModalOverride: topModalOverride
|
|
100
|
+
topModalOverride: topModalOverride,
|
|
101
|
+
restoreFocusOnClose: restoreFocusOnClose
|
|
100
102
|
}, componentTags), /*#__PURE__*/_react.default.createElement(_focusTrap.default, {
|
|
101
103
|
autoFocus: !disableAutoFocus,
|
|
102
104
|
focusFirstElement: focusFirstElement,
|
|
@@ -21,6 +21,10 @@ export interface ModalProps extends Omit<TagProps, "data-component"> {
|
|
|
21
21
|
timeout?: number;
|
|
22
22
|
/** Manually override the internal modal stacking order to set this as top */
|
|
23
23
|
topModalOverride?: boolean;
|
|
24
|
+
/** Enables the automatic restoration of focus to the element that invoked
|
|
25
|
+
* the modal when the modal is closed.
|
|
26
|
+
*/
|
|
27
|
+
restoreFocusOnClose?: boolean;
|
|
24
28
|
}
|
|
25
|
-
declare const Modal: ({ children, "data-element": dataElement, "data-role": dataRole, open, onCancel, disableEscKey, disableClose, enableBackgroundUI, timeout, topModalOverride, ...rest }: ModalProps) => React.JSX.Element;
|
|
29
|
+
declare const Modal: ({ children, "data-element": dataElement, "data-role": dataRole, open, onCancel, disableEscKey, disableClose, enableBackgroundUI, timeout, topModalOverride, restoreFocusOnClose, ...rest }: ModalProps) => React.JSX.Element;
|
|
26
30
|
export default Modal;
|
|
@@ -30,6 +30,7 @@ const Modal = ({
|
|
|
30
30
|
enableBackgroundUI = false,
|
|
31
31
|
timeout = 300,
|
|
32
32
|
topModalOverride,
|
|
33
|
+
restoreFocusOnClose = true,
|
|
33
34
|
...rest
|
|
34
35
|
}) => {
|
|
35
36
|
if (!deprecatedClassNameWarningShown && rest.className) {
|
|
@@ -74,7 +75,7 @@ const Modal = ({
|
|
|
74
75
|
modalRef: ref,
|
|
75
76
|
setTriggerRefocusFlag,
|
|
76
77
|
topModalOverride,
|
|
77
|
-
focusCallToActionElement: document.activeElement
|
|
78
|
+
focusCallToActionElement: restoreFocusOnClose ? document.activeElement : undefined
|
|
78
79
|
});
|
|
79
80
|
let background;
|
|
80
81
|
let content;
|
|
@@ -5,7 +5,7 @@ import { TagProps } from "../../__internal__/utils/helpers/tags/tags";
|
|
|
5
5
|
declare type CustomRefObject<T> = {
|
|
6
6
|
current?: T | null;
|
|
7
7
|
};
|
|
8
|
-
export interface SidebarProps extends PaddingProps, Omit<TagProps, "data-component">, WidthProps, Pick<ModalProps, "topModalOverride"> {
|
|
8
|
+
export interface SidebarProps extends PaddingProps, Omit<TagProps, "data-component">, WidthProps, Pick<ModalProps, "topModalOverride" | "restoreFocusOnClose"> {
|
|
9
9
|
/** Prop to specify the aria-describedby property of the component */
|
|
10
10
|
"aria-describedby"?: string;
|
|
11
11
|
/**
|
|
@@ -46,6 +46,7 @@ const Sidebar = exports.Sidebar = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
46
46
|
width,
|
|
47
47
|
headerPadding = {},
|
|
48
48
|
topModalOverride,
|
|
49
|
+
restoreFocusOnClose = true,
|
|
49
50
|
...rest
|
|
50
51
|
}, ref) => {
|
|
51
52
|
const locale = (0, _useLocale.default)();
|
|
@@ -101,7 +102,8 @@ const Sidebar = exports.Sidebar = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
101
102
|
onCancel: onCancel,
|
|
102
103
|
disableEscKey: disableEscKey,
|
|
103
104
|
enableBackgroundUI: enableBackgroundUI,
|
|
104
|
-
topModalOverride: topModalOverride
|
|
105
|
+
topModalOverride: topModalOverride,
|
|
106
|
+
restoreFocusOnClose: restoreFocusOnClose
|
|
105
107
|
}, enableBackgroundUI ? sidebar : /*#__PURE__*/_react.default.createElement(_focusTrap.default, {
|
|
106
108
|
wrapperRef: sidebarRef,
|
|
107
109
|
isOpen: open,
|
|
@@ -457,6 +459,7 @@ if (process.env.NODE_ENV !== "production") {
|
|
|
457
459
|
"toString": _propTypes.default.func.isRequired,
|
|
458
460
|
"valueOf": _propTypes.default.func.isRequired
|
|
459
461
|
}), _propTypes.default.string]),
|
|
462
|
+
"restoreFocusOnClose": _propTypes.default.bool,
|
|
460
463
|
"role": _propTypes.default.string,
|
|
461
464
|
"size": _propTypes.default.oneOf(["extra-large", "extra-small", "large", "medium-large", "medium-small", "medium", "small"]),
|
|
462
465
|
"topModalOverride": _propTypes.default.bool,
|
|
@@ -41,7 +41,8 @@ const VerticalMenuFullScreen = ({
|
|
|
41
41
|
open: isOpen,
|
|
42
42
|
closeModal: handleKeyDown,
|
|
43
43
|
modalRef: menuWrapperRef,
|
|
44
|
-
topModalOverride: true
|
|
44
|
+
topModalOverride: true,
|
|
45
|
+
focusCallToActionElement: document.activeElement
|
|
45
46
|
});
|
|
46
47
|
|
|
47
48
|
// TODO remove this as part of FE-5650
|