@atlaskit/drawer 7.5.5 → 7.6.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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @atlaskit/drawer
2
2
 
3
+ ## 7.6.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`288b53175c0`](https://bitbucket.org/atlassian/atlassian-frontend/commits/288b53175c0) - [ux] We are testing focus trap behavior for drawer in screen reader mode behind a feature flag. Now focus is set to first element and does not go beyond the content of the modal dialog. If this fix is successful, it will be available in a later release.
8
+
3
9
  ## 7.5.5
4
10
 
5
11
  ### Patch Changes
@@ -27,7 +27,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
27
27
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
28
28
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } /* eslint-disable @repo/internal/dom-events/no-unsafe-event-listeners */
29
29
  var packageName = "@atlaskit/drawer";
30
- var packageVersion = "7.5.5";
30
+ var packageVersion = "7.6.0";
31
31
  var createAndFireEventOnAtlaskit = (0, _analyticsNext.createAndFireEvent)('atlaskit');
32
32
  var createAndFireOnClick = function createAndFireOnClick(createAnalyticsEvent, trigger) {
33
33
  return createAndFireEventOnAtlaskit({
@@ -128,7 +128,9 @@ var DrawerBase = /*#__PURE__*/function (_Component) {
128
128
  shouldReturnFocus = _this$props3.shouldReturnFocus,
129
129
  overrides = _this$props3.overrides,
130
130
  _this$props3$zIndex = _this$props3.zIndex,
131
- zIndex = _this$props3$zIndex === void 0 ? 'unset' : _this$props3$zIndex;
131
+ zIndex = _this$props3$zIndex === void 0 ? 'unset' : _this$props3$zIndex,
132
+ label = _this$props3.label,
133
+ titleId = _this$props3.titleId;
132
134
  return /*#__PURE__*/_react.default.createElement(_portal.default, {
133
135
  zIndex: zIndex
134
136
  }, /*#__PURE__*/_react.default.createElement(_blanket.default, {
@@ -143,6 +145,8 @@ var DrawerBase = /*#__PURE__*/function (_Component) {
143
145
  onCloseComplete: onCloseComplete,
144
146
  onOpenComplete: onOpenComplete,
145
147
  width: width,
148
+ label: label,
149
+ titleId: titleId,
146
150
  shouldUnmountOnExit: shouldUnmountOnExit
147
151
  // eslint-disable-next-line @repo/internal/react/no-unsafe-overrides
148
152
  ,
@@ -5,10 +5,12 @@ Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.wrapperWidth = exports.default = void 0;
8
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
8
9
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
10
  var _react = require("react");
10
11
  var _react2 = require("@emotion/react");
11
12
  var _useCallbackRef = require("use-callback-ref");
13
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
12
14
  var _colors = require("@atlaskit/theme/colors");
13
15
  var _tokens = require("@atlaskit/tokens");
14
16
  var _usePreventProgrammaticScroll = _interopRequireDefault(require("./hooks/use-prevent-programmatic-scroll"));
@@ -50,7 +52,9 @@ var DrawerWrapper = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, scrollRe
50
52
  _ref$width = _ref.width,
51
53
  width = _ref$width === void 0 ? 'narrow' : _ref$width,
52
54
  testId = _ref.testId,
53
- drawerRef = _ref.drawerRef;
55
+ drawerRef = _ref.drawerRef,
56
+ label = _ref.label,
57
+ titleId = _ref.titleId;
54
58
  /**
55
59
  * We use a callback ref to assign the `<Content />` component to the forwarded `scrollRef`.
56
60
  * This ref comes from `react-scrolllock` to allow touch scrolling, eg.: `<ScrollLock><TouchScrollable>{children}</TouchScrollable><ScrollLock>`
@@ -67,13 +71,19 @@ var DrawerWrapper = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, scrollRe
67
71
  }, [scrollRef]);
68
72
  var ref = (0, _useCallbackRef.useMergeRefs)([drawerRef, assignSecondChildRef]);
69
73
  (0, _usePreventProgrammaticScroll.default)();
70
- return (0, _react2.jsx)("div", {
74
+ var modalDialogAttributes = (0, _platformFeatureFlags.getBooleanFF)('platform.design-system-team.drawer-screen-reader-focus-trap-refactor_hfuxc') && {
75
+ 'aria-modal': true,
76
+ role: 'dialog',
77
+ 'aria-label': label,
78
+ 'aria-labelledby': titleId
79
+ };
80
+ return (0, _react2.jsx)("div", (0, _extends2.default)({
71
81
  css: wrapperStyles,
72
82
  style: wrapperWidth[width],
73
83
  className: className,
74
84
  "data-testid": testId,
75
85
  ref: ref
76
- }, children);
86
+ }, modalDialogAttributes), children);
77
87
  });
78
88
  var _default = DrawerWrapper;
79
89
  exports.default = _default;
@@ -63,7 +63,9 @@ var DrawerPrimitive = function DrawerPrimitive(_ref2) {
63
63
  shouldReturnFocus = _ref2.shouldReturnFocus,
64
64
  autoFocusFirstElem = _ref2.autoFocusFirstElem,
65
65
  isFocusLockEnabled = _ref2.isFocusLockEnabled,
66
- width = _ref2.width;
66
+ width = _ref2.width,
67
+ label = _ref2.label,
68
+ titleId = _ref2.titleId;
67
69
  var getOverrides = (0, _utils.createExtender)(defaults, overrides);
68
70
  var _getOverrides = getOverrides('Sidebar'),
69
71
  Sidebar = _getOverrides.component,
@@ -97,7 +99,9 @@ var DrawerPrimitive = function DrawerPrimitive(_ref2) {
97
99
  className: className,
98
100
  width: width,
99
101
  testId: testId,
100
- drawerRef: drawerRef
102
+ drawerRef: drawerRef,
103
+ label: label,
104
+ titleId: titleId
101
105
  }, (0, _react2.jsx)(Sidebar, sideBarOverrides, (0, _react2.jsx)(_iconButton.default, {
102
106
  onClick: onClose,
103
107
  testId: testId && 'DrawerPrimitiveSidebarCloseButton'
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.widths = exports.transitionTimingFunction = exports.transitionDurationMs = exports.transitionDuration = exports.defaultFocusLockSettings = exports.animationTimingFunction = void 0;
7
7
  var _curves = require("@atlaskit/motion/curves");
8
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
8
9
  var transitionDuration = '0.22s';
9
10
  exports.transitionDuration = transitionDuration;
10
11
  var transitionDurationMs = 220;
@@ -20,6 +21,6 @@ exports.animationTimingFunction = animationTimingFunction;
20
21
  var defaultFocusLockSettings = {
21
22
  isFocusLockEnabled: true,
22
23
  shouldReturnFocus: true,
23
- autoFocusFirstElem: false
24
+ autoFocusFirstElem: (0, _platformFeatureFlags.getBooleanFF)('platform.design-system-team.drawer-screen-reader-focus-trap-refactor_hfuxc') || false
24
25
  };
25
26
  exports.defaultFocusLockSettings = defaultFocusLockSettings;
@@ -8,7 +8,7 @@ import { defaultFocusLockSettings } from '../constants';
8
8
  import Blanket from './blanket';
9
9
  import DrawerPrimitive from './primitives';
10
10
  const packageName = "@atlaskit/drawer";
11
- const packageVersion = "7.5.5";
11
+ const packageVersion = "7.6.0";
12
12
  const createAndFireEventOnAtlaskit = createAndFireEvent('atlaskit');
13
13
  const createAndFireOnClick = (createAnalyticsEvent, trigger) => createAndFireEventOnAtlaskit({
14
14
  action: 'dismissed',
@@ -96,7 +96,9 @@ export class DrawerBase extends Component {
96
96
  isFocusLockEnabled,
97
97
  shouldReturnFocus,
98
98
  overrides,
99
- zIndex = 'unset'
99
+ zIndex = 'unset',
100
+ label,
101
+ titleId
100
102
  } = this.props;
101
103
  return /*#__PURE__*/React.createElement(Portal, {
102
104
  zIndex: zIndex
@@ -112,6 +114,8 @@ export class DrawerBase extends Component {
112
114
  onCloseComplete: onCloseComplete,
113
115
  onOpenComplete: onOpenComplete,
114
116
  width: width,
117
+ label: label,
118
+ titleId: titleId,
115
119
  shouldUnmountOnExit: shouldUnmountOnExit
116
120
  // eslint-disable-next-line @repo/internal/react/no-unsafe-overrides
117
121
  ,
@@ -1,8 +1,9 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
1
2
  /** @jsx jsx */
2
-
3
3
  import { forwardRef, useCallback } from 'react';
4
4
  import { css, jsx } from '@emotion/react';
5
5
  import { useMergeRefs } from 'use-callback-ref';
6
+ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
6
7
  import { N0 } from '@atlaskit/theme/colors';
7
8
  import { CURRENT_SURFACE_CSS_VAR } from '@atlaskit/tokens';
8
9
  import usePreventProgrammaticScroll from './hooks/use-prevent-programmatic-scroll';
@@ -42,7 +43,9 @@ const DrawerWrapper = /*#__PURE__*/forwardRef(({
42
43
  className,
43
44
  width = 'narrow',
44
45
  testId,
45
- drawerRef
46
+ drawerRef,
47
+ label,
48
+ titleId
46
49
  }, scrollRef) => {
47
50
  /**
48
51
  * We use a callback ref to assign the `<Content />` component to the forwarded `scrollRef`.
@@ -60,12 +63,18 @@ const DrawerWrapper = /*#__PURE__*/forwardRef(({
60
63
  }, [scrollRef]);
61
64
  const ref = useMergeRefs([drawerRef, assignSecondChildRef]);
62
65
  usePreventProgrammaticScroll();
63
- return jsx("div", {
66
+ const modalDialogAttributes = getBooleanFF('platform.design-system-team.drawer-screen-reader-focus-trap-refactor_hfuxc') && {
67
+ 'aria-modal': true,
68
+ role: 'dialog',
69
+ 'aria-label': label,
70
+ 'aria-labelledby': titleId
71
+ };
72
+ return jsx("div", _extends({
64
73
  css: wrapperStyles,
65
74
  style: wrapperWidth[width],
66
75
  className: className,
67
76
  "data-testid": testId,
68
77
  ref: ref
69
- }, children);
78
+ }, modalDialogAttributes), children);
70
79
  });
71
80
  export default DrawerWrapper;
@@ -58,7 +58,9 @@ const DrawerPrimitive = ({
58
58
  shouldReturnFocus,
59
59
  autoFocusFirstElem,
60
60
  isFocusLockEnabled,
61
- width
61
+ width,
62
+ label,
63
+ titleId
62
64
  }) => {
63
65
  const getOverrides = createExtender(defaults, overrides);
64
66
  const {
@@ -95,7 +97,9 @@ const DrawerPrimitive = ({
95
97
  className: className,
96
98
  width: width,
97
99
  testId: testId,
98
- drawerRef: drawerRef
100
+ drawerRef: drawerRef,
101
+ label: label,
102
+ titleId: titleId
99
103
  }, jsx(Sidebar, sideBarOverrides, jsx(IconButton, {
100
104
  onClick: onClose,
101
105
  testId: testId && 'DrawerPrimitiveSidebarCloseButton'
@@ -1,4 +1,5 @@
1
1
  import { easeOut } from '@atlaskit/motion/curves';
2
+ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
2
3
  export const transitionDuration = '0.22s';
3
4
  export const transitionDurationMs = 220;
4
5
  export const transitionTimingFunction = easeOut;
@@ -7,5 +8,5 @@ export const animationTimingFunction = () => easeOut;
7
8
  export const defaultFocusLockSettings = {
8
9
  isFocusLockEnabled: true,
9
10
  shouldReturnFocus: true,
10
- autoFocusFirstElem: false
11
+ autoFocusFirstElem: getBooleanFF('platform.design-system-team.drawer-screen-reader-focus-trap-refactor_hfuxc') || false
11
12
  };
@@ -18,7 +18,7 @@ import { defaultFocusLockSettings } from '../constants';
18
18
  import Blanket from './blanket';
19
19
  import DrawerPrimitive from './primitives';
20
20
  var packageName = "@atlaskit/drawer";
21
- var packageVersion = "7.5.5";
21
+ var packageVersion = "7.6.0";
22
22
  var createAndFireEventOnAtlaskit = createAndFireEvent('atlaskit');
23
23
  var createAndFireOnClick = function createAndFireOnClick(createAnalyticsEvent, trigger) {
24
24
  return createAndFireEventOnAtlaskit({
@@ -119,7 +119,9 @@ export var DrawerBase = /*#__PURE__*/function (_Component) {
119
119
  shouldReturnFocus = _this$props3.shouldReturnFocus,
120
120
  overrides = _this$props3.overrides,
121
121
  _this$props3$zIndex = _this$props3.zIndex,
122
- zIndex = _this$props3$zIndex === void 0 ? 'unset' : _this$props3$zIndex;
122
+ zIndex = _this$props3$zIndex === void 0 ? 'unset' : _this$props3$zIndex,
123
+ label = _this$props3.label,
124
+ titleId = _this$props3.titleId;
123
125
  return /*#__PURE__*/React.createElement(Portal, {
124
126
  zIndex: zIndex
125
127
  }, /*#__PURE__*/React.createElement(Blanket, {
@@ -134,6 +136,8 @@ export var DrawerBase = /*#__PURE__*/function (_Component) {
134
136
  onCloseComplete: onCloseComplete,
135
137
  onOpenComplete: onOpenComplete,
136
138
  width: width,
139
+ label: label,
140
+ titleId: titleId,
137
141
  shouldUnmountOnExit: shouldUnmountOnExit
138
142
  // eslint-disable-next-line @repo/internal/react/no-unsafe-overrides
139
143
  ,
@@ -1,10 +1,11 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
1
2
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
3
  var _css;
3
4
  /** @jsx jsx */
4
-
5
5
  import { forwardRef, useCallback } from 'react';
6
6
  import { css, jsx } from '@emotion/react';
7
7
  import { useMergeRefs } from 'use-callback-ref';
8
+ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
8
9
  import { N0 } from '@atlaskit/theme/colors';
9
10
  import { CURRENT_SURFACE_CSS_VAR } from '@atlaskit/tokens';
10
11
  import usePreventProgrammaticScroll from './hooks/use-prevent-programmatic-scroll';
@@ -43,7 +44,9 @@ var DrawerWrapper = /*#__PURE__*/forwardRef(function (_ref, scrollRef) {
43
44
  _ref$width = _ref.width,
44
45
  width = _ref$width === void 0 ? 'narrow' : _ref$width,
45
46
  testId = _ref.testId,
46
- drawerRef = _ref.drawerRef;
47
+ drawerRef = _ref.drawerRef,
48
+ label = _ref.label,
49
+ titleId = _ref.titleId;
47
50
  /**
48
51
  * We use a callback ref to assign the `<Content />` component to the forwarded `scrollRef`.
49
52
  * This ref comes from `react-scrolllock` to allow touch scrolling, eg.: `<ScrollLock><TouchScrollable>{children}</TouchScrollable><ScrollLock>`
@@ -60,12 +63,18 @@ var DrawerWrapper = /*#__PURE__*/forwardRef(function (_ref, scrollRef) {
60
63
  }, [scrollRef]);
61
64
  var ref = useMergeRefs([drawerRef, assignSecondChildRef]);
62
65
  usePreventProgrammaticScroll();
63
- return jsx("div", {
66
+ var modalDialogAttributes = getBooleanFF('platform.design-system-team.drawer-screen-reader-focus-trap-refactor_hfuxc') && {
67
+ 'aria-modal': true,
68
+ role: 'dialog',
69
+ 'aria-label': label,
70
+ 'aria-labelledby': titleId
71
+ };
72
+ return jsx("div", _extends({
64
73
  css: wrapperStyles,
65
74
  style: wrapperWidth[width],
66
75
  className: className,
67
76
  "data-testid": testId,
68
77
  ref: ref
69
- }, children);
78
+ }, modalDialogAttributes), children);
70
79
  });
71
80
  export default DrawerWrapper;
@@ -59,7 +59,9 @@ var DrawerPrimitive = function DrawerPrimitive(_ref2) {
59
59
  shouldReturnFocus = _ref2.shouldReturnFocus,
60
60
  autoFocusFirstElem = _ref2.autoFocusFirstElem,
61
61
  isFocusLockEnabled = _ref2.isFocusLockEnabled,
62
- width = _ref2.width;
62
+ width = _ref2.width,
63
+ label = _ref2.label,
64
+ titleId = _ref2.titleId;
63
65
  var getOverrides = createExtender(defaults, overrides);
64
66
  var _getOverrides = getOverrides('Sidebar'),
65
67
  Sidebar = _getOverrides.component,
@@ -93,7 +95,9 @@ var DrawerPrimitive = function DrawerPrimitive(_ref2) {
93
95
  className: className,
94
96
  width: width,
95
97
  testId: testId,
96
- drawerRef: drawerRef
98
+ drawerRef: drawerRef,
99
+ label: label,
100
+ titleId: titleId
97
101
  }, jsx(Sidebar, sideBarOverrides, jsx(IconButton, {
98
102
  onClick: onClose,
99
103
  testId: testId && 'DrawerPrimitiveSidebarCloseButton'
@@ -1,4 +1,5 @@
1
1
  import { easeOut } from '@atlaskit/motion/curves';
2
+ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
2
3
  export var transitionDuration = '0.22s';
3
4
  export var transitionDurationMs = 220;
4
5
  export var transitionTimingFunction = easeOut;
@@ -9,5 +10,5 @@ export var animationTimingFunction = function animationTimingFunction() {
9
10
  export var defaultFocusLockSettings = {
10
11
  isFocusLockEnabled: true,
11
12
  shouldReturnFocus: true,
12
- autoFocusFirstElem: false
13
+ autoFocusFirstElem: getBooleanFF('platform.design-system-team.drawer-screen-reader-focus-trap-refactor_hfuxc') || false
13
14
  };
@@ -22,10 +22,10 @@ export declare class DrawerBase extends Component<DrawerProps, {
22
22
  handleKeyDown: (event: KeyboardEvent) => void;
23
23
  render(): JSX.Element | null;
24
24
  }
25
- declare const _default: React.ForwardRefExoticComponent<Pick<Pick<Omit<DrawerProps, keyof import("@atlaskit/analytics-next").WithAnalyticsEventsProps>, "children" | "onKeyDown" | "onClose" | "testId" | "icon" | "onOpenComplete" | "onCloseComplete" | "shouldUnmountOnExit" | "overrides" | "zIndex" | "isOpen"> & Partial<Pick<Omit<DrawerProps, keyof import("@atlaskit/analytics-next").WithAnalyticsEventsProps>, "width" | keyof import("./types").FocusLockSettings>> & Partial<Pick<{
25
+ declare const _default: React.ForwardRefExoticComponent<Pick<Pick<Omit<DrawerProps, keyof import("@atlaskit/analytics-next").WithAnalyticsEventsProps>, "children" | "onKeyDown" | "onClose" | "testId" | "icon" | "onOpenComplete" | "onCloseComplete" | "shouldUnmountOnExit" | "overrides" | "zIndex" | "isOpen" | keyof import("./types").DrawerLabel> & Partial<Pick<Omit<DrawerProps, keyof import("@atlaskit/analytics-next").WithAnalyticsEventsProps>, "width" | keyof import("./types").FocusLockSettings>> & Partial<Pick<{
26
26
  autoFocusFirstElem?: boolean | (() => HTMLElement | null) | undefined;
27
27
  isFocusLockEnabled?: boolean | undefined;
28
28
  shouldReturnFocus?: boolean | undefined;
29
29
  width: DrawerWidth;
30
- }, never>> & React.RefAttributes<any> & import("@atlaskit/analytics-next").WithContextProps, "width" | "children" | "onKeyDown" | "key" | "onClose" | "testId" | "icon" | "onOpenComplete" | "onCloseComplete" | "shouldUnmountOnExit" | "overrides" | "zIndex" | "isOpen" | "analyticsContext" | keyof import("./types").FocusLockSettings> & React.RefAttributes<any>>;
30
+ }, never>> & React.RefAttributes<any> & import("@atlaskit/analytics-next").WithContextProps, "width" | "children" | "onKeyDown" | "key" | "onClose" | "testId" | "icon" | "onOpenComplete" | "onCloseComplete" | "shouldUnmountOnExit" | "overrides" | "zIndex" | "isOpen" | "analyticsContext" | keyof import("./types").FocusLockSettings | keyof import("./types").DrawerLabel> & React.RefAttributes<any>>;
31
31
  export default _default;
@@ -2,7 +2,7 @@
2
2
  import { ReactElement, Ref } from 'react';
3
3
  import { DrawerPrimitiveProps, Widths } from '../types';
4
4
  export declare const wrapperWidth: Widths;
5
- interface FocusLockRefTargetProps extends Pick<DrawerPrimitiveProps, 'width' | 'testId'> {
5
+ interface FocusLockRefTargetProps extends Pick<DrawerPrimitiveProps, 'width' | 'testId' | 'label' | 'titleId'> {
6
6
  /**
7
7
  * This must have two children explicitly as we target the second child as the Content.
8
8
  */
@@ -1,5 +1,5 @@
1
1
  /** @jsx jsx */
2
2
  import { jsx } from '@emotion/react';
3
3
  import { DrawerPrimitiveProps } from '../types';
4
- declare const DrawerPrimitive: ({ children, icon: Icon, onClose, onCloseComplete, onOpenComplete, overrides, testId, in: isOpen, shouldReturnFocus, autoFocusFirstElem, isFocusLockEnabled, width, }: DrawerPrimitiveProps) => jsx.JSX.Element;
4
+ declare const DrawerPrimitive: ({ children, icon: Icon, onClose, onCloseComplete, onOpenComplete, overrides, testId, in: isOpen, shouldReturnFocus, autoFocusFirstElem, isFocusLockEnabled, width, label, titleId, }: DrawerPrimitiveProps) => jsx.JSX.Element;
5
5
  export default DrawerPrimitive;
@@ -54,6 +54,18 @@ export interface BaseProps {
54
54
  */
55
55
  overrides?: OverridesType;
56
56
  }
57
+ export interface DrawerLabel {
58
+ /**
59
+ * Refers to an aria-label attribute. Sets an accessible name for drawer wrapper to announce it to users of assistive technology.
60
+ * Usage of either this, or the `titleId` attribute is strongly recommended.
61
+ */
62
+ label?: string;
63
+ /**
64
+ * Id referenced by the drawer wrapper's aria-labelledby attribute. This id should be assigned to the drawer title element.
65
+ * Usage of either this, or the `label` attribute is strongly recommended.
66
+ */
67
+ titleId?: string;
68
+ }
57
69
  export type DefaultsType = {
58
70
  Sidebar: {
59
71
  component: React.ComponentType<SidebarProps>;
@@ -96,11 +108,11 @@ export interface ContentProps extends React.HTMLProps<HTMLDivElement> {
96
108
  cssFn: (defaultStyles: CSSObject) => CSSObject;
97
109
  }
98
110
  export type ContentCSSProps = Omit<ContentProps, 'cssFn'>;
99
- export interface DrawerPrimitiveProps extends BaseProps, FocusLockSettings {
111
+ export interface DrawerPrimitiveProps extends BaseProps, FocusLockSettings, DrawerLabel {
100
112
  in: boolean;
101
113
  onClose: (event: SyntheticEvent<HTMLElement>) => void;
102
114
  }
103
- export type DrawerProps = BaseProps & FocusLockSettings & WithAnalyticsEventsProps & {
115
+ export type DrawerProps = BaseProps & FocusLockSettings & WithAnalyticsEventsProps & DrawerLabel & {
104
116
  /**
105
117
  * Callback function called while the drawer is displayed and `keydown` event is triggered.
106
118
  */
@@ -122,7 +134,7 @@ export type DrawerProps = BaseProps & FocusLockSettings & WithAnalyticsEventsPro
122
134
  };
123
135
  export interface FocusLockSettings {
124
136
  /**
125
- * Controls whether to focus the first tabbable element inside the focus lock.
137
+ * Controls whether to focus the first tabbable element inside the focus lock. Set to `true` by default.
126
138
  */
127
139
  autoFocusFirstElem?: boolean | (() => HTMLElement | null);
128
140
  /**
@@ -130,14 +142,14 @@ export interface FocusLockSettings {
130
142
  */
131
143
  isFocusLockEnabled?: boolean;
132
144
  /**
133
- * Whether to return the focus to the previous active element on closing the drawer.
145
+ * Controls whether to return the focus to the previous active element on closing the drawer. Set to `true` by default.
134
146
  */
135
147
  shouldReturnFocus?: boolean;
136
148
  }
137
149
  export interface FocusLockProps extends FocusLockSettings {
138
150
  /**
139
151
  * Content inside the focus lock.
140
- * Must strictly be a ReactElement and it *must* be implemented to take a `ref` passed from `react-scrolllock` to enable Touch Scrolling.
152
+ * Must strictly be a ReactElement and it *must* be implemented to take a `ref` passed from `react-scrollock` to enable Touch Scrolling.
141
153
  */
142
154
  children?: ReactElement;
143
155
  }
@@ -22,10 +22,10 @@ export declare class DrawerBase extends Component<DrawerProps, {
22
22
  handleKeyDown: (event: KeyboardEvent) => void;
23
23
  render(): JSX.Element | null;
24
24
  }
25
- declare const _default: React.ForwardRefExoticComponent<Pick<Pick<Omit<DrawerProps, keyof import("@atlaskit/analytics-next").WithAnalyticsEventsProps>, "children" | "onKeyDown" | "onClose" | "testId" | "icon" | "onOpenComplete" | "onCloseComplete" | "shouldUnmountOnExit" | "overrides" | "zIndex" | "isOpen"> & Partial<Pick<Omit<DrawerProps, keyof import("@atlaskit/analytics-next").WithAnalyticsEventsProps>, "width" | keyof import("./types").FocusLockSettings>> & Partial<Pick<{
25
+ declare const _default: React.ForwardRefExoticComponent<Pick<Pick<Omit<DrawerProps, keyof import("@atlaskit/analytics-next").WithAnalyticsEventsProps>, "children" | "onKeyDown" | "onClose" | "testId" | "icon" | "onOpenComplete" | "onCloseComplete" | "shouldUnmountOnExit" | "overrides" | "zIndex" | "isOpen" | keyof import("./types").DrawerLabel> & Partial<Pick<Omit<DrawerProps, keyof import("@atlaskit/analytics-next").WithAnalyticsEventsProps>, "width" | keyof import("./types").FocusLockSettings>> & Partial<Pick<{
26
26
  autoFocusFirstElem?: boolean | (() => HTMLElement | null) | undefined;
27
27
  isFocusLockEnabled?: boolean | undefined;
28
28
  shouldReturnFocus?: boolean | undefined;
29
29
  width: DrawerWidth;
30
- }, never>> & React.RefAttributes<any> & import("@atlaskit/analytics-next").WithContextProps, "width" | "children" | "onKeyDown" | "key" | "onClose" | "testId" | "icon" | "onOpenComplete" | "onCloseComplete" | "shouldUnmountOnExit" | "overrides" | "zIndex" | "isOpen" | "analyticsContext" | keyof import("./types").FocusLockSettings> & React.RefAttributes<any>>;
30
+ }, never>> & React.RefAttributes<any> & import("@atlaskit/analytics-next").WithContextProps, "width" | "children" | "onKeyDown" | "key" | "onClose" | "testId" | "icon" | "onOpenComplete" | "onCloseComplete" | "shouldUnmountOnExit" | "overrides" | "zIndex" | "isOpen" | "analyticsContext" | keyof import("./types").FocusLockSettings | keyof import("./types").DrawerLabel> & React.RefAttributes<any>>;
31
31
  export default _default;
@@ -2,7 +2,7 @@
2
2
  import { ReactElement, Ref } from 'react';
3
3
  import { DrawerPrimitiveProps, Widths } from '../types';
4
4
  export declare const wrapperWidth: Widths;
5
- interface FocusLockRefTargetProps extends Pick<DrawerPrimitiveProps, 'width' | 'testId'> {
5
+ interface FocusLockRefTargetProps extends Pick<DrawerPrimitiveProps, 'width' | 'testId' | 'label' | 'titleId'> {
6
6
  /**
7
7
  * This must have two children explicitly as we target the second child as the Content.
8
8
  */
@@ -1,5 +1,5 @@
1
1
  /** @jsx jsx */
2
2
  import { jsx } from '@emotion/react';
3
3
  import { DrawerPrimitiveProps } from '../types';
4
- declare const DrawerPrimitive: ({ children, icon: Icon, onClose, onCloseComplete, onOpenComplete, overrides, testId, in: isOpen, shouldReturnFocus, autoFocusFirstElem, isFocusLockEnabled, width, }: DrawerPrimitiveProps) => jsx.JSX.Element;
4
+ declare const DrawerPrimitive: ({ children, icon: Icon, onClose, onCloseComplete, onOpenComplete, overrides, testId, in: isOpen, shouldReturnFocus, autoFocusFirstElem, isFocusLockEnabled, width, label, titleId, }: DrawerPrimitiveProps) => jsx.JSX.Element;
5
5
  export default DrawerPrimitive;
@@ -54,6 +54,18 @@ export interface BaseProps {
54
54
  */
55
55
  overrides?: OverridesType;
56
56
  }
57
+ export interface DrawerLabel {
58
+ /**
59
+ * Refers to an aria-label attribute. Sets an accessible name for drawer wrapper to announce it to users of assistive technology.
60
+ * Usage of either this, or the `titleId` attribute is strongly recommended.
61
+ */
62
+ label?: string;
63
+ /**
64
+ * Id referenced by the drawer wrapper's aria-labelledby attribute. This id should be assigned to the drawer title element.
65
+ * Usage of either this, or the `label` attribute is strongly recommended.
66
+ */
67
+ titleId?: string;
68
+ }
57
69
  export type DefaultsType = {
58
70
  Sidebar: {
59
71
  component: React.ComponentType<SidebarProps>;
@@ -96,11 +108,11 @@ export interface ContentProps extends React.HTMLProps<HTMLDivElement> {
96
108
  cssFn: (defaultStyles: CSSObject) => CSSObject;
97
109
  }
98
110
  export type ContentCSSProps = Omit<ContentProps, 'cssFn'>;
99
- export interface DrawerPrimitiveProps extends BaseProps, FocusLockSettings {
111
+ export interface DrawerPrimitiveProps extends BaseProps, FocusLockSettings, DrawerLabel {
100
112
  in: boolean;
101
113
  onClose: (event: SyntheticEvent<HTMLElement>) => void;
102
114
  }
103
- export type DrawerProps = BaseProps & FocusLockSettings & WithAnalyticsEventsProps & {
115
+ export type DrawerProps = BaseProps & FocusLockSettings & WithAnalyticsEventsProps & DrawerLabel & {
104
116
  /**
105
117
  * Callback function called while the drawer is displayed and `keydown` event is triggered.
106
118
  */
@@ -122,7 +134,7 @@ export type DrawerProps = BaseProps & FocusLockSettings & WithAnalyticsEventsPro
122
134
  };
123
135
  export interface FocusLockSettings {
124
136
  /**
125
- * Controls whether to focus the first tabbable element inside the focus lock.
137
+ * Controls whether to focus the first tabbable element inside the focus lock. Set to `true` by default.
126
138
  */
127
139
  autoFocusFirstElem?: boolean | (() => HTMLElement | null);
128
140
  /**
@@ -130,14 +142,14 @@ export interface FocusLockSettings {
130
142
  */
131
143
  isFocusLockEnabled?: boolean;
132
144
  /**
133
- * Whether to return the focus to the previous active element on closing the drawer.
145
+ * Controls whether to return the focus to the previous active element on closing the drawer. Set to `true` by default.
134
146
  */
135
147
  shouldReturnFocus?: boolean;
136
148
  }
137
149
  export interface FocusLockProps extends FocusLockSettings {
138
150
  /**
139
151
  * Content inside the focus lock.
140
- * Must strictly be a ReactElement and it *must* be implemented to take a `ref` passed from `react-scrolllock` to enable Touch Scrolling.
152
+ * Must strictly be a ReactElement and it *must* be implemented to take a `ref` passed from `react-scrollock` to enable Touch Scrolling.
141
153
  */
142
154
  children?: ReactElement;
143
155
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/drawer",
3
- "version": "7.5.5",
3
+ "version": "7.6.0",
4
4
  "description": "A drawer is a panel that slides in from the left side of the screen.",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -37,9 +37,10 @@
37
37
  "@atlaskit/blanket": "^12.4.0",
38
38
  "@atlaskit/icon": "^21.12.0",
39
39
  "@atlaskit/motion": "^1.4.0",
40
+ "@atlaskit/platform-feature-flags": "^0.2.0",
40
41
  "@atlaskit/portal": "^4.3.0",
41
- "@atlaskit/theme": "^12.5.0",
42
- "@atlaskit/tokens": "^1.18.0",
42
+ "@atlaskit/theme": "^12.6.0",
43
+ "@atlaskit/tokens": "^1.22.0",
43
44
  "@babel/runtime": "^7.0.0",
44
45
  "@emotion/react": "^11.7.1",
45
46
  "bind-event-listener": "^2.1.1",
@@ -54,12 +55,14 @@
54
55
  },
55
56
  "devDependencies": {
56
57
  "@af/accessibility-testing": "*",
58
+ "@af/integration-testing": "*",
57
59
  "@af/visual-regression": "*",
58
60
  "@atlaskit/ds-lib": "^2.2.0",
59
61
  "@atlaskit/ssr": "*",
60
62
  "@atlaskit/visual-regression": "*",
61
63
  "@atlaskit/webdriver-runner": "*",
62
64
  "@atlassian/atlassian-frontend-prettier-config-1.0.1": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.1",
65
+ "@atlassian/feature-flags-test-utils": "*",
63
66
  "@testing-library/react": "^12.1.5",
64
67
  "@testing-library/user-event": "^14.4.3",
65
68
  "lodash": "^4.17.21",
@@ -90,5 +93,10 @@
90
93
  ]
91
94
  }
92
95
  },
93
- "prettier": "@atlassian/atlassian-frontend-prettier-config-1.0.1"
96
+ "prettier": "@atlassian/atlassian-frontend-prettier-config-1.0.1",
97
+ "platform-feature-flags": {
98
+ "platform.design-system-team.drawer-screen-reader-focus-trap-refactor_hfuxc": {
99
+ "type": "boolean"
100
+ }
101
+ }
94
102
  }
package/report.api.md CHANGED
@@ -65,6 +65,7 @@ const _default: React_2.ForwardRefExoticComponent<
65
65
  | 'shouldUnmountOnExit'
66
66
  | 'testId'
67
67
  | 'zIndex'
68
+ | keyof DrawerLabel
68
69
  > &
69
70
  Partial<
70
71
  Pick<
@@ -102,6 +103,7 @@ const _default: React_2.ForwardRefExoticComponent<
102
103
  | 'testId'
103
104
  | 'width'
104
105
  | 'zIndex'
106
+ | keyof DrawerLabel
105
107
  | keyof FocusLockSettings
106
108
  > &
107
109
  React_2.RefAttributes<any>
@@ -120,6 +122,12 @@ export type DefaultsType = {
120
122
  };
121
123
  };
122
124
 
125
+ // @public (undocumented)
126
+ interface DrawerLabel {
127
+ label?: string;
128
+ titleId?: string;
129
+ }
130
+
123
131
  // @public (undocumented)
124
132
  export type DrawerPrimitiveDefaults = Pick<DefaultsType, 'Content' | 'Sidebar'>;
125
133
 
@@ -130,7 +138,10 @@ export type DrawerPrimitiveOverrides = Pick<
130
138
  >;
131
139
 
132
140
  // @public (undocumented)
133
- export interface DrawerPrimitiveProps extends BaseProps, FocusLockSettings {
141
+ export interface DrawerPrimitiveProps
142
+ extends BaseProps,
143
+ FocusLockSettings,
144
+ DrawerLabel {
134
145
  // (undocumented)
135
146
  in: boolean;
136
147
  // (undocumented)
@@ -140,7 +151,8 @@ export interface DrawerPrimitiveProps extends BaseProps, FocusLockSettings {
140
151
  // @public (undocumented)
141
152
  export type DrawerProps = BaseProps &
142
153
  FocusLockSettings &
143
- WithAnalyticsEventsProps & {
154
+ WithAnalyticsEventsProps &
155
+ DrawerLabel & {
144
156
  onKeyDown?: (event: SyntheticEvent) => void;
145
157
  onClose?: (event: SyntheticEvent<HTMLElement>, analyticsEvent: any) => void;
146
158
  isOpen: boolean;
@@ -39,12 +39,12 @@ export interface ContentProps extends React.HTMLProps<HTMLDivElement> {
39
39
  }
40
40
 
41
41
  // @public (undocumented)
42
- const _default: React_2.ForwardRefExoticComponent<Pick<Pick<Omit<DrawerProps, keyof WithAnalyticsEventsProps>, "children" | "icon" | "isOpen" | "onClose" | "onCloseComplete" | "onKeyDown" | "onOpenComplete" | "overrides" | "shouldUnmountOnExit" | "testId" | "zIndex"> & Partial<Pick<Omit<DrawerProps, keyof WithAnalyticsEventsProps>, "width" | keyof FocusLockSettings>> & Partial<Pick<{
42
+ const _default: React_2.ForwardRefExoticComponent<Pick<Pick<Omit<DrawerProps, keyof WithAnalyticsEventsProps>, "children" | "icon" | "isOpen" | "onClose" | "onCloseComplete" | "onKeyDown" | "onOpenComplete" | "overrides" | "shouldUnmountOnExit" | "testId" | "zIndex" | keyof DrawerLabel> & Partial<Pick<Omit<DrawerProps, keyof WithAnalyticsEventsProps>, "width" | keyof FocusLockSettings>> & Partial<Pick<{
43
43
  autoFocusFirstElem?: (() => HTMLElement | null) | boolean | undefined;
44
44
  isFocusLockEnabled?: boolean | undefined;
45
45
  shouldReturnFocus?: boolean | undefined;
46
46
  width: DrawerWidth;
47
- }, never>> & React_2.RefAttributes<any> & WithContextProps, "analyticsContext" | "children" | "icon" | "isOpen" | "key" | "onClose" | "onCloseComplete" | "onKeyDown" | "onOpenComplete" | "overrides" | "shouldUnmountOnExit" | "testId" | "width" | "zIndex" | keyof FocusLockSettings> & React_2.RefAttributes<any>>;
47
+ }, never>> & React_2.RefAttributes<any> & WithContextProps, "analyticsContext" | "children" | "icon" | "isOpen" | "key" | "onClose" | "onCloseComplete" | "onKeyDown" | "onOpenComplete" | "overrides" | "shouldUnmountOnExit" | "testId" | "width" | "zIndex" | keyof DrawerLabel| keyof FocusLockSettings > & React_2.RefAttributes<any>>;
48
48
  export default _default;
49
49
 
50
50
  // @public (undocumented)
@@ -59,6 +59,12 @@ export type DefaultsType = {
59
59
  };
60
60
  };
61
61
 
62
+ // @public (undocumented)
63
+ interface DrawerLabel {
64
+ label?: string;
65
+ titleId?: string;
66
+ }
67
+
62
68
  // @public (undocumented)
63
69
  export type DrawerPrimitiveDefaults = Pick<DefaultsType, 'Content' | 'Sidebar'>;
64
70
 
@@ -66,7 +72,7 @@ export type DrawerPrimitiveDefaults = Pick<DefaultsType, 'Content' | 'Sidebar'>;
66
72
  export type DrawerPrimitiveOverrides = Pick<OverridesType, 'Content' | 'Sidebar'>;
67
73
 
68
74
  // @public (undocumented)
69
- export interface DrawerPrimitiveProps extends BaseProps, FocusLockSettings {
75
+ export interface DrawerPrimitiveProps extends BaseProps, FocusLockSettings, DrawerLabel {
70
76
  // (undocumented)
71
77
  in: boolean;
72
78
  // (undocumented)
@@ -74,7 +80,7 @@ export interface DrawerPrimitiveProps extends BaseProps, FocusLockSettings {
74
80
  }
75
81
 
76
82
  // @public (undocumented)
77
- export type DrawerProps = BaseProps & FocusLockSettings & WithAnalyticsEventsProps & {
83
+ export type DrawerProps = BaseProps & FocusLockSettings & WithAnalyticsEventsProps & DrawerLabel & {
78
84
  onKeyDown?: (event: SyntheticEvent) => void;
79
85
  onClose?: (event: SyntheticEvent<HTMLElement>, analyticsEvent: any) => void;
80
86
  isOpen: boolean;