@zendeskgarden/react-modals 8.62.2 → 8.63.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/dist/index.cjs.js CHANGED
@@ -143,7 +143,7 @@ const COMPONENT_ID$j = 'modals.backdrop';
143
143
  const animationName$1 = styled.keyframes(["0%{opacity:0;}100%{opacity:1;}"]);
144
144
  const StyledBackdrop = styled__default.default.div.attrs({
145
145
  'data-garden-id': COMPONENT_ID$j,
146
- 'data-garden-version': '8.62.2'
146
+ 'data-garden-version': '8.63.1'
147
147
  }).withConfig({
148
148
  displayName: "StyledBackdrop",
149
149
  componentId: "sc-mzdjpo-0"
@@ -159,7 +159,7 @@ StyledBackdrop.propTypes = {
159
159
  const COMPONENT_ID$i = 'modals.body';
160
160
  const StyledBody = styled__default.default.div.attrs({
161
161
  'data-garden-id': COMPONENT_ID$i,
162
- 'data-garden-version': '8.62.2'
162
+ 'data-garden-version': '8.63.1'
163
163
  }).withConfig({
164
164
  displayName: "StyledBody",
165
165
  componentId: "sc-14rzecg-0"
@@ -181,7 +181,7 @@ const BASE_MULTIPLIERS$1 = {
181
181
  };
182
182
  const StyledClose = styled__default.default.button.attrs({
183
183
  'data-garden-id': COMPONENT_ID$h,
184
- 'data-garden-version': '8.62.2'
184
+ 'data-garden-version': '8.63.1'
185
185
  }).withConfig({
186
186
  displayName: "StyledClose",
187
187
  componentId: "sc-iseudj-0"
@@ -193,7 +193,7 @@ StyledClose.defaultProps = {
193
193
  const COMPONENT_ID$g = 'modals.footer';
194
194
  const StyledFooter = styled__default.default.div.attrs({
195
195
  'data-garden-id': COMPONENT_ID$g,
196
- 'data-garden-version': '8.62.2'
196
+ 'data-garden-version': '8.63.1'
197
197
  }).withConfig({
198
198
  displayName: "StyledFooter",
199
199
  componentId: "sc-d8pfdu-0"
@@ -205,7 +205,7 @@ StyledFooter.defaultProps = {
205
205
  const COMPONENT_ID$f = 'modals.footer_item';
206
206
  const StyledFooterItem = styled__default.default.span.attrs({
207
207
  'data-garden-id': COMPONENT_ID$f,
208
- 'data-garden-version': '8.62.2'
208
+ 'data-garden-version': '8.63.1'
209
209
  }).withConfig({
210
210
  displayName: "StyledFooterItem",
211
211
  componentId: "sc-1mb76hl-0"
@@ -217,7 +217,7 @@ StyledFooterItem.defaultProps = {
217
217
  const COMPONENT_ID$e = 'modals.header';
218
218
  const StyledHeader = styled__default.default.div.attrs({
219
219
  'data-garden-id': COMPONENT_ID$e,
220
- 'data-garden-version': '8.62.2'
220
+ 'data-garden-version': '8.63.1'
221
221
  }).withConfig({
222
222
  displayName: "StyledHeader",
223
223
  componentId: "sc-1787r9v-0"
@@ -227,9 +227,7 @@ StyledHeader.defaultProps = {
227
227
  };
228
228
 
229
229
  var _g, _circle;
230
-
231
230
  function _extends$1() { _extends$1 = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$1.apply(this, arguments); }
232
-
233
231
  var SvgAlertErrorStroke = function SvgAlertErrorStroke(props) {
234
232
  return /*#__PURE__*/React__namespace.createElement("svg", _extends$1({
235
233
  xmlns: "http://www.w3.org/2000/svg",
@@ -237,8 +235,7 @@ var SvgAlertErrorStroke = function SvgAlertErrorStroke(props) {
237
235
  height: 16,
238
236
  focusable: "false",
239
237
  viewBox: "0 0 16 16",
240
- "aria-hidden": "true",
241
- role: "img"
238
+ "aria-hidden": "true"
242
239
  }, props), _g || (_g = /*#__PURE__*/React__namespace.createElement("g", {
243
240
  fill: "none",
244
241
  stroke: "currentColor"
@@ -285,7 +282,7 @@ const sizeStyles$1 = props => {
285
282
  };
286
283
  const StyledModal = styled__default.default.div.attrs({
287
284
  'data-garden-id': COMPONENT_ID$d,
288
- 'data-garden-version': '8.62.2'
285
+ 'data-garden-version': '8.63.1'
289
286
  }).withConfig({
290
287
  displayName: "StyledModal",
291
288
  componentId: "sc-1pe1axu-0"
@@ -301,7 +298,7 @@ StyledModal.defaultProps = {
301
298
  const COMPONENT_ID$c = 'modals.tooltip_modal.backdrop';
302
299
  const StyledTooltipModalBackdrop = styled__default.default.div.attrs({
303
300
  'data-garden-id': COMPONENT_ID$c,
304
- 'data-garden-version': '8.62.2'
301
+ 'data-garden-version': '8.63.1'
305
302
  }).withConfig({
306
303
  displayName: "StyledTooltipModalBackdrop",
307
304
  componentId: "sc-1yaomgq-0"
@@ -384,7 +381,7 @@ StyledTooltipWrapper.defaultProps = {
384
381
  const COMPONENT_ID$b = 'modals.tooltip_modal';
385
382
  const StyledTooltipModal = styled__default.default.div.attrs(props => ({
386
383
  'data-garden-id': COMPONENT_ID$b,
387
- 'data-garden-version': '8.62.2',
384
+ 'data-garden-version': '8.63.1',
388
385
  className: props.isAnimated && 'is-animated'
389
386
  })).withConfig({
390
387
  displayName: "StyledTooltipModal",
@@ -413,7 +410,7 @@ const sizeStyles = props => `
413
410
  `;
414
411
  const StyledTooltipModalTitle = styled__default.default.div.attrs({
415
412
  'data-garden-id': COMPONENT_ID$a,
416
- 'data-garden-version': '8.62.2'
413
+ 'data-garden-version': '8.63.1'
417
414
  }).withConfig({
418
415
  displayName: "StyledTooltipModalTitle",
419
416
  componentId: "sc-11xjgjs-0"
@@ -425,7 +422,7 @@ StyledTooltipModalTitle.defaultProps = {
425
422
  const COMPONENT_ID$9 = 'modals.tooltip_modal.body';
426
423
  const StyledTooltipModalBody = styled__default.default.div.attrs({
427
424
  'data-garden-id': COMPONENT_ID$9,
428
- 'data-garden-version': '8.62.2'
425
+ 'data-garden-version': '8.63.1'
429
426
  }).withConfig({
430
427
  displayName: "StyledTooltipModalBody",
431
428
  componentId: "sc-195dkzj-0"
@@ -437,7 +434,7 @@ StyledTooltipModalBody.defaultProps = {
437
434
  const COMPONENT_ID$8 = 'modals.tooltip_modal.footer';
438
435
  const StyledTooltipModalFooter = styled__default.default.div.attrs({
439
436
  'data-garden-id': COMPONENT_ID$8,
440
- 'data-garden-version': '8.62.2'
437
+ 'data-garden-version': '8.63.1'
441
438
  }).withConfig({
442
439
  displayName: "StyledTooltipModalFooter",
443
440
  componentId: "sc-fm36a9-0"
@@ -449,7 +446,7 @@ StyledTooltipModalFooter.defaultProps = {
449
446
  const COMPONENT_ID$7 = 'modals.tooltip_modal.footer_item';
450
447
  const StyledTooltipModalFooterItem = styled__default.default(StyledFooterItem).attrs({
451
448
  'data-garden-id': COMPONENT_ID$7,
452
- 'data-garden-version': '8.62.2'
449
+ 'data-garden-version': '8.63.1'
453
450
  }).withConfig({
454
451
  displayName: "StyledTooltipModalFooterItem",
455
452
  componentId: "sc-1nahj6p-0"
@@ -461,7 +458,7 @@ StyledTooltipModalFooterItem.defaultProps = {
461
458
  const COMPONENT_ID$6 = 'modals.tooltip_modal.close';
462
459
  const StyledTooltipModalClose = styled__default.default(StyledClose).attrs({
463
460
  'data-garden-id': COMPONENT_ID$6,
464
- 'data-garden-version': '8.62.2'
461
+ 'data-garden-version': '8.63.1'
465
462
  }).withConfig({
466
463
  displayName: "StyledTooltipModalClose",
467
464
  componentId: "sc-1h2ke3q-0"
@@ -487,7 +484,7 @@ const boxShadow = props => {
487
484
  };
488
485
  const StyledDrawerModal = styled__default.default.div.attrs({
489
486
  'data-garden-id': COMPONENT_ID$5,
490
- 'data-garden-version': '8.62.2'
487
+ 'data-garden-version': '8.63.1'
491
488
  }).withConfig({
492
489
  displayName: "StyledDrawerModal",
493
490
  componentId: "sc-i1sake-0"
@@ -504,7 +501,7 @@ const BASE_MULTIPLIERS = {
504
501
  };
505
502
  const StyledDrawerModalClose = styled__default.default(StyledClose).attrs({
506
503
  'data-garden-id': COMPONENT_ID$4,
507
- 'data-garden-version': '8.62.2'
504
+ 'data-garden-version': '8.63.1'
508
505
  }).withConfig({
509
506
  displayName: "StyledDrawerModalClose",
510
507
  componentId: "sc-hrnaom-0"
@@ -516,7 +513,7 @@ StyledDrawerModalClose.defaultProps = {
516
513
  const COMPONENT_ID$3 = 'modals.drawer_modal.header';
517
514
  const StyledDrawerModalHeader = styled__default.default(StyledHeader).attrs({
518
515
  'data-garden-id': COMPONENT_ID$3,
519
- 'data-garden-version': '8.62.2'
516
+ 'data-garden-version': '8.63.1'
520
517
  }).withConfig({
521
518
  displayName: "StyledDrawerModalHeader",
522
519
  componentId: "sc-1u04rqw-0"
@@ -528,7 +525,7 @@ StyledDrawerModalHeader.defaultProps = {
528
525
  const COMPONENT_ID$2 = 'modals.drawer_modal.body';
529
526
  const StyledDrawerModalBody = styled__default.default(StyledBody).attrs({
530
527
  'data-garden-id': COMPONENT_ID$2,
531
- 'data-garden-version': '8.62.2'
528
+ 'data-garden-version': '8.63.1'
532
529
  }).withConfig({
533
530
  displayName: "StyledDrawerModalBody",
534
531
  componentId: "sc-yafe2y-0"
@@ -540,7 +537,7 @@ StyledDrawerModalBody.defaultProps = {
540
537
  const COMPONENT_ID$1 = 'modals.drawer_modal.footer';
541
538
  const StyledDrawerModalFooter = styled__default.default.div.attrs({
542
539
  'data-garden-id': COMPONENT_ID$1,
543
- 'data-garden-version': '8.62.2'
540
+ 'data-garden-version': '8.63.1'
544
541
  }).withConfig({
545
542
  displayName: "StyledDrawerModalFooter",
546
543
  componentId: "sc-17if4ka-0"
@@ -552,7 +549,7 @@ StyledDrawerModalFooter.defaultProps = {
552
549
  const COMPONENT_ID = 'modals.drawer_modal.footer_item';
553
550
  const StyledDrawerModalFooterItem = styled__default.default(StyledFooterItem).attrs({
554
551
  'data-garden-id': COMPONENT_ID,
555
- 'data-garden-version': '8.62.2'
552
+ 'data-garden-version': '8.63.1'
556
553
  }).withConfig({
557
554
  displayName: "StyledDrawerModalFooterItem",
558
555
  componentId: "sc-1vbl885-0"
@@ -722,9 +719,7 @@ const Body$2 = React.forwardRef((props, ref) => {
722
719
  Body$2.displayName = 'Body';
723
720
 
724
721
  var _path;
725
-
726
722
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
727
-
728
723
  var SvgXStroke = function SvgXStroke(props) {
729
724
  return /*#__PURE__*/React__namespace.createElement("svg", _extends({
730
725
  xmlns: "http://www.w3.org/2000/svg",
@@ -732,8 +727,7 @@ var SvgXStroke = function SvgXStroke(props) {
732
727
  height: 16,
733
728
  focusable: "false",
734
729
  viewBox: "0 0 16 16",
735
- "aria-hidden": "true",
736
- role: "img"
730
+ "aria-hidden": "true"
737
731
  }, props), _path || (_path = /*#__PURE__*/React__namespace.createElement("path", {
738
732
  stroke: "currentColor",
739
733
  strokeLinecap: "round",
@@ -1023,6 +1017,19 @@ TooltipModal.Footer = Footer$1;
1023
1017
  TooltipModal.FooterItem = FooterItem$1;
1024
1018
  TooltipModal.Title = Title;
1025
1019
 
1020
+ function activeElement(doc) {
1021
+ if (doc === void 0) {
1022
+ doc = ownerDocument();
1023
+ }
1024
+ try {
1025
+ var active = doc.activeElement;
1026
+ if (!active || !active.nodeName) return null;
1027
+ return active;
1028
+ } catch (e) {
1029
+ return doc.body;
1030
+ }
1031
+ }
1032
+
1026
1033
  const HeaderComponent = React.forwardRef((_ref, ref) => {
1027
1034
  let {
1028
1035
  tag,
@@ -1115,6 +1122,7 @@ const DrawerModalComponent = React.forwardRef((_ref, ref) => {
1115
1122
  } = _ref;
1116
1123
  const modalRef = React.useRef(null);
1117
1124
  const transitionRef = React.useRef(null);
1125
+ const triggerRef = React.useRef(null);
1118
1126
  const theme = React.useContext(styled.ThemeContext);
1119
1127
  const environment = reactTheming.useDocument(theme);
1120
1128
  const [isCloseButtonPresent, setIsCloseButtonPresent] = React.useState(false);
@@ -1132,11 +1140,31 @@ const DrawerModalComponent = React.forwardRef((_ref, ref) => {
1132
1140
  } = containerModal.useModal({
1133
1141
  idPrefix: id,
1134
1142
  modalRef,
1135
- focusOnMount,
1136
- restoreFocus,
1143
+ focusOnMount: false ,
1144
+ restoreFocus: false ,
1137
1145
  environment,
1138
1146
  onClose
1139
1147
  });
1148
+ React.useEffect(() => {
1149
+ if (environment) {
1150
+ if (isOpen && modalRef.current) {
1151
+ if (restoreFocus) {
1152
+ triggerRef.current = activeElement(environment);
1153
+ }
1154
+ if (focusOnMount) {
1155
+ modalRef.current.focus();
1156
+ }
1157
+ }
1158
+ if (!isOpen && triggerRef.current) {
1159
+ triggerRef.current.focus();
1160
+ }
1161
+ }
1162
+ return () => {
1163
+ if (!(restoreFocus && isOpen)) {
1164
+ triggerRef.current = null;
1165
+ }
1166
+ };
1167
+ }, [environment, restoreFocus, focusOnMount, isOpen]);
1140
1168
  React.useEffect(() => {
1141
1169
  if (!environment) {
1142
1170
  return undefined;
@@ -1211,6 +1239,10 @@ DrawerModalComponent.propTypes = {
1211
1239
  appendToNode: PropTypes__default.default.any,
1212
1240
  isOpen: PropTypes__default.default.bool
1213
1241
  };
1242
+ DrawerModalComponent.defaultProps = {
1243
+ focusOnMount: true ,
1244
+ restoreFocus: true
1245
+ };
1214
1246
  const DrawerModal = DrawerModalComponent;
1215
1247
  DrawerModal.Body = Body;
1216
1248
  DrawerModal.Close = Close;
package/dist/index.esm.js CHANGED
@@ -116,7 +116,7 @@ const COMPONENT_ID$j = 'modals.backdrop';
116
116
  const animationName$1 = keyframes(["0%{opacity:0;}100%{opacity:1;}"]);
117
117
  const StyledBackdrop = styled.div.attrs({
118
118
  'data-garden-id': COMPONENT_ID$j,
119
- 'data-garden-version': '8.62.2'
119
+ 'data-garden-version': '8.63.1'
120
120
  }).withConfig({
121
121
  displayName: "StyledBackdrop",
122
122
  componentId: "sc-mzdjpo-0"
@@ -132,7 +132,7 @@ StyledBackdrop.propTypes = {
132
132
  const COMPONENT_ID$i = 'modals.body';
133
133
  const StyledBody = styled.div.attrs({
134
134
  'data-garden-id': COMPONENT_ID$i,
135
- 'data-garden-version': '8.62.2'
135
+ 'data-garden-version': '8.63.1'
136
136
  }).withConfig({
137
137
  displayName: "StyledBody",
138
138
  componentId: "sc-14rzecg-0"
@@ -154,7 +154,7 @@ const BASE_MULTIPLIERS$1 = {
154
154
  };
155
155
  const StyledClose = styled.button.attrs({
156
156
  'data-garden-id': COMPONENT_ID$h,
157
- 'data-garden-version': '8.62.2'
157
+ 'data-garden-version': '8.63.1'
158
158
  }).withConfig({
159
159
  displayName: "StyledClose",
160
160
  componentId: "sc-iseudj-0"
@@ -166,7 +166,7 @@ StyledClose.defaultProps = {
166
166
  const COMPONENT_ID$g = 'modals.footer';
167
167
  const StyledFooter = styled.div.attrs({
168
168
  'data-garden-id': COMPONENT_ID$g,
169
- 'data-garden-version': '8.62.2'
169
+ 'data-garden-version': '8.63.1'
170
170
  }).withConfig({
171
171
  displayName: "StyledFooter",
172
172
  componentId: "sc-d8pfdu-0"
@@ -178,7 +178,7 @@ StyledFooter.defaultProps = {
178
178
  const COMPONENT_ID$f = 'modals.footer_item';
179
179
  const StyledFooterItem = styled.span.attrs({
180
180
  'data-garden-id': COMPONENT_ID$f,
181
- 'data-garden-version': '8.62.2'
181
+ 'data-garden-version': '8.63.1'
182
182
  }).withConfig({
183
183
  displayName: "StyledFooterItem",
184
184
  componentId: "sc-1mb76hl-0"
@@ -190,7 +190,7 @@ StyledFooterItem.defaultProps = {
190
190
  const COMPONENT_ID$e = 'modals.header';
191
191
  const StyledHeader = styled.div.attrs({
192
192
  'data-garden-id': COMPONENT_ID$e,
193
- 'data-garden-version': '8.62.2'
193
+ 'data-garden-version': '8.63.1'
194
194
  }).withConfig({
195
195
  displayName: "StyledHeader",
196
196
  componentId: "sc-1787r9v-0"
@@ -200,9 +200,7 @@ StyledHeader.defaultProps = {
200
200
  };
201
201
 
202
202
  var _g, _circle;
203
-
204
203
  function _extends$1() { _extends$1 = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$1.apply(this, arguments); }
205
-
206
204
  var SvgAlertErrorStroke = function SvgAlertErrorStroke(props) {
207
205
  return /*#__PURE__*/React.createElement("svg", _extends$1({
208
206
  xmlns: "http://www.w3.org/2000/svg",
@@ -210,8 +208,7 @@ var SvgAlertErrorStroke = function SvgAlertErrorStroke(props) {
210
208
  height: 16,
211
209
  focusable: "false",
212
210
  viewBox: "0 0 16 16",
213
- "aria-hidden": "true",
214
- role: "img"
211
+ "aria-hidden": "true"
215
212
  }, props), _g || (_g = /*#__PURE__*/React.createElement("g", {
216
213
  fill: "none",
217
214
  stroke: "currentColor"
@@ -258,7 +255,7 @@ const sizeStyles$1 = props => {
258
255
  };
259
256
  const StyledModal = styled.div.attrs({
260
257
  'data-garden-id': COMPONENT_ID$d,
261
- 'data-garden-version': '8.62.2'
258
+ 'data-garden-version': '8.63.1'
262
259
  }).withConfig({
263
260
  displayName: "StyledModal",
264
261
  componentId: "sc-1pe1axu-0"
@@ -274,7 +271,7 @@ StyledModal.defaultProps = {
274
271
  const COMPONENT_ID$c = 'modals.tooltip_modal.backdrop';
275
272
  const StyledTooltipModalBackdrop = styled.div.attrs({
276
273
  'data-garden-id': COMPONENT_ID$c,
277
- 'data-garden-version': '8.62.2'
274
+ 'data-garden-version': '8.63.1'
278
275
  }).withConfig({
279
276
  displayName: "StyledTooltipModalBackdrop",
280
277
  componentId: "sc-1yaomgq-0"
@@ -357,7 +354,7 @@ StyledTooltipWrapper.defaultProps = {
357
354
  const COMPONENT_ID$b = 'modals.tooltip_modal';
358
355
  const StyledTooltipModal = styled.div.attrs(props => ({
359
356
  'data-garden-id': COMPONENT_ID$b,
360
- 'data-garden-version': '8.62.2',
357
+ 'data-garden-version': '8.63.1',
361
358
  className: props.isAnimated && 'is-animated'
362
359
  })).withConfig({
363
360
  displayName: "StyledTooltipModal",
@@ -386,7 +383,7 @@ const sizeStyles = props => `
386
383
  `;
387
384
  const StyledTooltipModalTitle = styled.div.attrs({
388
385
  'data-garden-id': COMPONENT_ID$a,
389
- 'data-garden-version': '8.62.2'
386
+ 'data-garden-version': '8.63.1'
390
387
  }).withConfig({
391
388
  displayName: "StyledTooltipModalTitle",
392
389
  componentId: "sc-11xjgjs-0"
@@ -398,7 +395,7 @@ StyledTooltipModalTitle.defaultProps = {
398
395
  const COMPONENT_ID$9 = 'modals.tooltip_modal.body';
399
396
  const StyledTooltipModalBody = styled.div.attrs({
400
397
  'data-garden-id': COMPONENT_ID$9,
401
- 'data-garden-version': '8.62.2'
398
+ 'data-garden-version': '8.63.1'
402
399
  }).withConfig({
403
400
  displayName: "StyledTooltipModalBody",
404
401
  componentId: "sc-195dkzj-0"
@@ -410,7 +407,7 @@ StyledTooltipModalBody.defaultProps = {
410
407
  const COMPONENT_ID$8 = 'modals.tooltip_modal.footer';
411
408
  const StyledTooltipModalFooter = styled.div.attrs({
412
409
  'data-garden-id': COMPONENT_ID$8,
413
- 'data-garden-version': '8.62.2'
410
+ 'data-garden-version': '8.63.1'
414
411
  }).withConfig({
415
412
  displayName: "StyledTooltipModalFooter",
416
413
  componentId: "sc-fm36a9-0"
@@ -422,7 +419,7 @@ StyledTooltipModalFooter.defaultProps = {
422
419
  const COMPONENT_ID$7 = 'modals.tooltip_modal.footer_item';
423
420
  const StyledTooltipModalFooterItem = styled(StyledFooterItem).attrs({
424
421
  'data-garden-id': COMPONENT_ID$7,
425
- 'data-garden-version': '8.62.2'
422
+ 'data-garden-version': '8.63.1'
426
423
  }).withConfig({
427
424
  displayName: "StyledTooltipModalFooterItem",
428
425
  componentId: "sc-1nahj6p-0"
@@ -434,7 +431,7 @@ StyledTooltipModalFooterItem.defaultProps = {
434
431
  const COMPONENT_ID$6 = 'modals.tooltip_modal.close';
435
432
  const StyledTooltipModalClose = styled(StyledClose).attrs({
436
433
  'data-garden-id': COMPONENT_ID$6,
437
- 'data-garden-version': '8.62.2'
434
+ 'data-garden-version': '8.63.1'
438
435
  }).withConfig({
439
436
  displayName: "StyledTooltipModalClose",
440
437
  componentId: "sc-1h2ke3q-0"
@@ -460,7 +457,7 @@ const boxShadow = props => {
460
457
  };
461
458
  const StyledDrawerModal = styled.div.attrs({
462
459
  'data-garden-id': COMPONENT_ID$5,
463
- 'data-garden-version': '8.62.2'
460
+ 'data-garden-version': '8.63.1'
464
461
  }).withConfig({
465
462
  displayName: "StyledDrawerModal",
466
463
  componentId: "sc-i1sake-0"
@@ -477,7 +474,7 @@ const BASE_MULTIPLIERS = {
477
474
  };
478
475
  const StyledDrawerModalClose = styled(StyledClose).attrs({
479
476
  'data-garden-id': COMPONENT_ID$4,
480
- 'data-garden-version': '8.62.2'
477
+ 'data-garden-version': '8.63.1'
481
478
  }).withConfig({
482
479
  displayName: "StyledDrawerModalClose",
483
480
  componentId: "sc-hrnaom-0"
@@ -489,7 +486,7 @@ StyledDrawerModalClose.defaultProps = {
489
486
  const COMPONENT_ID$3 = 'modals.drawer_modal.header';
490
487
  const StyledDrawerModalHeader = styled(StyledHeader).attrs({
491
488
  'data-garden-id': COMPONENT_ID$3,
492
- 'data-garden-version': '8.62.2'
489
+ 'data-garden-version': '8.63.1'
493
490
  }).withConfig({
494
491
  displayName: "StyledDrawerModalHeader",
495
492
  componentId: "sc-1u04rqw-0"
@@ -501,7 +498,7 @@ StyledDrawerModalHeader.defaultProps = {
501
498
  const COMPONENT_ID$2 = 'modals.drawer_modal.body';
502
499
  const StyledDrawerModalBody = styled(StyledBody).attrs({
503
500
  'data-garden-id': COMPONENT_ID$2,
504
- 'data-garden-version': '8.62.2'
501
+ 'data-garden-version': '8.63.1'
505
502
  }).withConfig({
506
503
  displayName: "StyledDrawerModalBody",
507
504
  componentId: "sc-yafe2y-0"
@@ -513,7 +510,7 @@ StyledDrawerModalBody.defaultProps = {
513
510
  const COMPONENT_ID$1 = 'modals.drawer_modal.footer';
514
511
  const StyledDrawerModalFooter = styled.div.attrs({
515
512
  'data-garden-id': COMPONENT_ID$1,
516
- 'data-garden-version': '8.62.2'
513
+ 'data-garden-version': '8.63.1'
517
514
  }).withConfig({
518
515
  displayName: "StyledDrawerModalFooter",
519
516
  componentId: "sc-17if4ka-0"
@@ -525,7 +522,7 @@ StyledDrawerModalFooter.defaultProps = {
525
522
  const COMPONENT_ID = 'modals.drawer_modal.footer_item';
526
523
  const StyledDrawerModalFooterItem = styled(StyledFooterItem).attrs({
527
524
  'data-garden-id': COMPONENT_ID,
528
- 'data-garden-version': '8.62.2'
525
+ 'data-garden-version': '8.63.1'
529
526
  }).withConfig({
530
527
  displayName: "StyledDrawerModalFooterItem",
531
528
  componentId: "sc-1vbl885-0"
@@ -695,9 +692,7 @@ const Body$2 = forwardRef((props, ref) => {
695
692
  Body$2.displayName = 'Body';
696
693
 
697
694
  var _path;
698
-
699
695
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
700
-
701
696
  var SvgXStroke = function SvgXStroke(props) {
702
697
  return /*#__PURE__*/React.createElement("svg", _extends({
703
698
  xmlns: "http://www.w3.org/2000/svg",
@@ -705,8 +700,7 @@ var SvgXStroke = function SvgXStroke(props) {
705
700
  height: 16,
706
701
  focusable: "false",
707
702
  viewBox: "0 0 16 16",
708
- "aria-hidden": "true",
709
- role: "img"
703
+ "aria-hidden": "true"
710
704
  }, props), _path || (_path = /*#__PURE__*/React.createElement("path", {
711
705
  stroke: "currentColor",
712
706
  strokeLinecap: "round",
@@ -996,6 +990,19 @@ TooltipModal.Footer = Footer$1;
996
990
  TooltipModal.FooterItem = FooterItem$1;
997
991
  TooltipModal.Title = Title;
998
992
 
993
+ function activeElement(doc) {
994
+ if (doc === void 0) {
995
+ doc = ownerDocument();
996
+ }
997
+ try {
998
+ var active = doc.activeElement;
999
+ if (!active || !active.nodeName) return null;
1000
+ return active;
1001
+ } catch (e) {
1002
+ return doc.body;
1003
+ }
1004
+ }
1005
+
999
1006
  const HeaderComponent = forwardRef((_ref, ref) => {
1000
1007
  let {
1001
1008
  tag,
@@ -1088,6 +1095,7 @@ const DrawerModalComponent = forwardRef((_ref, ref) => {
1088
1095
  } = _ref;
1089
1096
  const modalRef = useRef(null);
1090
1097
  const transitionRef = useRef(null);
1098
+ const triggerRef = useRef(null);
1091
1099
  const theme = useContext(ThemeContext);
1092
1100
  const environment = useDocument(theme);
1093
1101
  const [isCloseButtonPresent, setIsCloseButtonPresent] = useState(false);
@@ -1105,11 +1113,31 @@ const DrawerModalComponent = forwardRef((_ref, ref) => {
1105
1113
  } = useModal({
1106
1114
  idPrefix: id,
1107
1115
  modalRef,
1108
- focusOnMount,
1109
- restoreFocus,
1116
+ focusOnMount: false ,
1117
+ restoreFocus: false ,
1110
1118
  environment,
1111
1119
  onClose
1112
1120
  });
1121
+ useEffect(() => {
1122
+ if (environment) {
1123
+ if (isOpen && modalRef.current) {
1124
+ if (restoreFocus) {
1125
+ triggerRef.current = activeElement(environment);
1126
+ }
1127
+ if (focusOnMount) {
1128
+ modalRef.current.focus();
1129
+ }
1130
+ }
1131
+ if (!isOpen && triggerRef.current) {
1132
+ triggerRef.current.focus();
1133
+ }
1134
+ }
1135
+ return () => {
1136
+ if (!(restoreFocus && isOpen)) {
1137
+ triggerRef.current = null;
1138
+ }
1139
+ };
1140
+ }, [environment, restoreFocus, focusOnMount, isOpen]);
1113
1141
  useEffect(() => {
1114
1142
  if (!environment) {
1115
1143
  return undefined;
@@ -1184,6 +1212,10 @@ DrawerModalComponent.propTypes = {
1184
1212
  appendToNode: PropTypes.any,
1185
1213
  isOpen: PropTypes.bool
1186
1214
  };
1215
+ DrawerModalComponent.defaultProps = {
1216
+ focusOnMount: true ,
1217
+ restoreFocus: true
1218
+ };
1187
1219
  const DrawerModal = DrawerModalComponent;
1188
1220
  DrawerModal.Body = Body;
1189
1221
  DrawerModal.Close = Close;
@@ -7,7 +7,7 @@
7
7
  import { HTMLAttributes, KeyboardEvent, MouseEvent } from 'react';
8
8
  import { Modifier } from 'react-popper';
9
9
  export declare const PLACEMENT: readonly ["auto", "top", "top-start", "top-end", "bottom", "bottom-start", "bottom-end", "end", "end-top", "end-bottom", "start", "start-top", "start-bottom"];
10
- export declare type Placement = typeof PLACEMENT[number];
10
+ export type Placement = (typeof PLACEMENT)[number];
11
11
  export interface IModalProps extends HTMLAttributes<HTMLDivElement> {
12
12
  /**
13
13
  * Passes HTML attributes to the backdrop element
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zendeskgarden/react-modals",
3
- "version": "8.62.2",
3
+ "version": "8.63.1",
4
4
  "description": "Components relating to modals in the Garden Design System",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Zendesk Garden <garden@zendesk.com>",
@@ -39,7 +39,7 @@
39
39
  },
40
40
  "devDependencies": {
41
41
  "@types/react-transition-group": "4.4.5",
42
- "@zendeskgarden/react-theming": "^8.62.2",
42
+ "@zendeskgarden/react-theming": "^8.63.1",
43
43
  "@zendeskgarden/svg-icons": "6.33.0"
44
44
  },
45
45
  "keywords": [
@@ -52,5 +52,5 @@
52
52
  "access": "public"
53
53
  },
54
54
  "zendeskgarden:src": "src/index.ts",
55
- "gitHead": "27a7d6c021f3360396af60d51ecbf66e9076a405"
55
+ "gitHead": "1c1d67d2b98ee0539975cee53f457081e5ae479a"
56
56
  }