@react-aria/dialog 3.5.27 → 3.5.29

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.
@@ -1 +1 @@
1
- {"mappings":";;AAmBA;IACE,8CAA8C;IAC9C,WAAW,EAAE,aAAa,CAAC;IAE3B,0CAA0C;IAC1C,UAAU,EAAE,aAAa,CAAA;CAC1B;AAED;;;GAGG;AACH,0BAA0B,KAAK,EAAE,eAAe,EAAE,GAAG,EAAE,UAAU,gBAAgB,GAAG,IAAI,CAAC,GAAG,UAAU,CA4DrG;AC/ED,YAAY,EAAC,eAAe,EAAC,MAAM,qBAAqB,CAAC","sources":["packages/@react-aria/dialog/src/packages/@react-aria/dialog/src/useDialog.ts","packages/@react-aria/dialog/src/packages/@react-aria/dialog/src/index.ts","packages/@react-aria/dialog/src/index.ts"],"sourcesContent":[null,null,"/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\nexport {useDialog} from './useDialog';\nexport type {AriaDialogProps} from '@react-types/dialog';\nexport type {DialogAria} from './useDialog';\n"],"names":[],"version":3,"file":"types.d.ts.map"}
1
+ {"mappings":";;AAmBA;IACE,8CAA8C;IAC9C,WAAW,EAAE,aAAa,CAAC;IAE3B,0CAA0C;IAC1C,UAAU,EAAE,aAAa,CAAA;CAC1B;AAED;;;GAGG;AACH,0BAA0B,KAAK,EAAE,eAAe,EAAE,GAAG,EAAE,UAAU,gBAAgB,GAAG,IAAI,CAAC,GAAG,UAAU,CA6DrG;AChFD,YAAY,EAAC,eAAe,EAAC,MAAM,qBAAqB,CAAC","sources":["packages/@react-aria/dialog/src/packages/@react-aria/dialog/src/useDialog.ts","packages/@react-aria/dialog/src/packages/@react-aria/dialog/src/index.ts","packages/@react-aria/dialog/src/index.ts"],"sourcesContent":[null,null,"/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\nexport {useDialog} from './useDialog';\nexport type {AriaDialogProps} from '@react-types/dialog';\nexport type {DialogAria} from './useDialog';\n"],"names":[],"version":3,"file":"types.d.ts.map"}
@@ -36,7 +36,8 @@ function $e7b76b4fae4e4c55$export$d55e7ee900f34e93(props, ref) {
36
36
  // or announce that it has opened until it has rendered. A workaround
37
37
  // is to wait for half a second, then blur and re-focus the dialog.
38
38
  let timeout = setTimeout(()=>{
39
- if (document.activeElement === ref.current) {
39
+ // Check that the dialog is still focused, or focused was lost to the body.
40
+ if (document.activeElement === ref.current || document.activeElement === document.body) {
40
41
  isRefocusing.current = true;
41
42
  if (ref.current) {
42
43
  ref.current.blur();
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;AAqBM,SAAS,0CAAU,KAAsB,EAAE,GAAuC;IACvF,IAAI,QACF,OAAO,UACR,GAAG;IACJ,IAAI,UAA8B,CAAA,GAAA,+BAAQ;IAC1C,UAAU,KAAK,CAAC,aAAa,GAAG,YAAY;IAE5C,IAAI,eAAe,CAAA,GAAA,mBAAK,EAAE;IAE1B,+EAA+E;IAC/E,CAAA,GAAA,sBAAQ,EAAE;QACR,IAAI,IAAI,OAAO,IAAI,CAAC,IAAI,OAAO,CAAC,QAAQ,CAAC,SAAS,aAAa,GAAG;YAChE,CAAA,GAAA,wCAAU,EAAE,IAAI,OAAO;YAEvB,iEAAiE;YACjE,qEAAqE;YACrE,mEAAmE;YACnE,IAAI,UAAU,WAAW;gBACvB,IAAI,SAAS,aAAa,KAAK,IAAI,OAAO,EAAE;oBAC1C,aAAa,OAAO,GAAG;oBACvB,IAAI,IAAI,OAAO,EAAE;wBACf,IAAI,OAAO,CAAC,IAAI;wBAChB,CAAA,GAAA,wCAAU,EAAE,IAAI,OAAO;oBACzB;oBACA,aAAa,OAAO,GAAG;gBACzB;YACF,GAAG;YAEH,OAAO;gBACL,aAAa;YACf;QACF;IACF,GAAG;QAAC;KAAI;IAER,CAAA,GAAA,+CAAqB;IAErB,sGAAsG;IACtG,qFAAqF;IACrF,sDAAsD;IACtD,qGAAqG;IACrG,gDAAgD;IAChD,OAAO;QACL,aAAa;YACX,GAAG,CAAA,GAAA,oCAAa,EAAE,OAAO;gBAAC,WAAW;YAAI,EAAE;kBAC3C;YACA,UAAU;YACV,mBAAmB,KAAK,CAAC,kBAAkB,IAAI;YAC/C,gEAAgE;YAChE,iEAAiE;YACjE,0DAA0D;YAC1D,QAAQ,CAAA;gBACN,IAAI,aAAa,OAAO,EACtB,EAAE,eAAe;YAErB;QACF;QACA,YAAY;YACV,IAAI;QACN;IACF;AACF","sources":["packages/@react-aria/dialog/src/useDialog.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaDialogProps} from '@react-types/dialog';\nimport {DOMAttributes, FocusableElement, RefObject} from '@react-types/shared';\nimport {filterDOMProps, useSlotId} from '@react-aria/utils';\nimport {focusSafely} from '@react-aria/interactions';\nimport {useEffect, useRef} from 'react';\nimport {useOverlayFocusContain} from '@react-aria/overlays';\n\nexport interface DialogAria {\n /** Props for the dialog container element. */\n dialogProps: DOMAttributes,\n\n /** Props for the dialog title element. */\n titleProps: DOMAttributes\n}\n\n/**\n * Provides the behavior and accessibility implementation for a dialog component.\n * A dialog is an overlay shown above other content in an application.\n */\nexport function useDialog(props: AriaDialogProps, ref: RefObject<FocusableElement | null>): DialogAria {\n let {\n role = 'dialog'\n } = props;\n let titleId: string | undefined = useSlotId();\n titleId = props['aria-label'] ? undefined : titleId;\n\n let isRefocusing = useRef(false);\n\n // Focus the dialog itself on mount, unless a child element is already focused.\n useEffect(() => {\n if (ref.current && !ref.current.contains(document.activeElement)) {\n focusSafely(ref.current);\n\n // Safari on iOS does not move the VoiceOver cursor to the dialog\n // or announce that it has opened until it has rendered. A workaround\n // is to wait for half a second, then blur and re-focus the dialog.\n let timeout = setTimeout(() => {\n if (document.activeElement === ref.current) {\n isRefocusing.current = true;\n if (ref.current) {\n ref.current.blur();\n focusSafely(ref.current);\n }\n isRefocusing.current = false;\n }\n }, 500);\n\n return () => {\n clearTimeout(timeout);\n };\n }\n }, [ref]);\n\n useOverlayFocusContain();\n\n // We do not use aria-modal due to a Safari bug which forces the first focusable element to be focused\n // on mount when inside an iframe, no matter which element we programmatically focus.\n // See https://bugs.webkit.org/show_bug.cgi?id=211934.\n // useModal sets aria-hidden on all elements outside the dialog, so the dialog will behave as a modal\n // even without aria-modal on the dialog itself.\n return {\n dialogProps: {\n ...filterDOMProps(props, {labelable: true}),\n role,\n tabIndex: -1,\n 'aria-labelledby': props['aria-labelledby'] || titleId,\n // Prevent blur events from reaching useOverlay, which may cause\n // popovers to close. Since focus is contained within the dialog,\n // we don't want this to occur due to the above useEffect.\n onBlur: e => {\n if (isRefocusing.current) {\n e.stopPropagation();\n }\n }\n },\n titleProps: {\n id: titleId\n }\n };\n}\n"],"names":[],"version":3,"file":"useDialog.main.js.map"}
1
+ {"mappings":";;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;AAqBM,SAAS,0CAAU,KAAsB,EAAE,GAAuC;IACvF,IAAI,QACF,OAAO,UACR,GAAG;IACJ,IAAI,UAA8B,CAAA,GAAA,+BAAQ;IAC1C,UAAU,KAAK,CAAC,aAAa,GAAG,YAAY;IAE5C,IAAI,eAAe,CAAA,GAAA,mBAAK,EAAE;IAE1B,+EAA+E;IAC/E,CAAA,GAAA,sBAAQ,EAAE;QACR,IAAI,IAAI,OAAO,IAAI,CAAC,IAAI,OAAO,CAAC,QAAQ,CAAC,SAAS,aAAa,GAAG;YAChE,CAAA,GAAA,wCAAU,EAAE,IAAI,OAAO;YAEvB,iEAAiE;YACjE,qEAAqE;YACrE,mEAAmE;YACnE,IAAI,UAAU,WAAW;gBACvB,2EAA2E;gBAC3E,IAAI,SAAS,aAAa,KAAK,IAAI,OAAO,IAAI,SAAS,aAAa,KAAK,SAAS,IAAI,EAAE;oBACtF,aAAa,OAAO,GAAG;oBACvB,IAAI,IAAI,OAAO,EAAE;wBACf,IAAI,OAAO,CAAC,IAAI;wBAChB,CAAA,GAAA,wCAAU,EAAE,IAAI,OAAO;oBACzB;oBACA,aAAa,OAAO,GAAG;gBACzB;YACF,GAAG;YAEH,OAAO;gBACL,aAAa;YACf;QACF;IACF,GAAG;QAAC;KAAI;IAER,CAAA,GAAA,+CAAqB;IAErB,sGAAsG;IACtG,qFAAqF;IACrF,sDAAsD;IACtD,qGAAqG;IACrG,gDAAgD;IAChD,OAAO;QACL,aAAa;YACX,GAAG,CAAA,GAAA,oCAAa,EAAE,OAAO;gBAAC,WAAW;YAAI,EAAE;kBAC3C;YACA,UAAU;YACV,mBAAmB,KAAK,CAAC,kBAAkB,IAAI;YAC/C,gEAAgE;YAChE,iEAAiE;YACjE,0DAA0D;YAC1D,QAAQ,CAAA;gBACN,IAAI,aAAa,OAAO,EACtB,EAAE,eAAe;YAErB;QACF;QACA,YAAY;YACV,IAAI;QACN;IACF;AACF","sources":["packages/@react-aria/dialog/src/useDialog.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaDialogProps} from '@react-types/dialog';\nimport {DOMAttributes, FocusableElement, RefObject} from '@react-types/shared';\nimport {filterDOMProps, useSlotId} from '@react-aria/utils';\nimport {focusSafely} from '@react-aria/interactions';\nimport {useEffect, useRef} from 'react';\nimport {useOverlayFocusContain} from '@react-aria/overlays';\n\nexport interface DialogAria {\n /** Props for the dialog container element. */\n dialogProps: DOMAttributes,\n\n /** Props for the dialog title element. */\n titleProps: DOMAttributes\n}\n\n/**\n * Provides the behavior and accessibility implementation for a dialog component.\n * A dialog is an overlay shown above other content in an application.\n */\nexport function useDialog(props: AriaDialogProps, ref: RefObject<FocusableElement | null>): DialogAria {\n let {\n role = 'dialog'\n } = props;\n let titleId: string | undefined = useSlotId();\n titleId = props['aria-label'] ? undefined : titleId;\n\n let isRefocusing = useRef(false);\n\n // Focus the dialog itself on mount, unless a child element is already focused.\n useEffect(() => {\n if (ref.current && !ref.current.contains(document.activeElement)) {\n focusSafely(ref.current);\n\n // Safari on iOS does not move the VoiceOver cursor to the dialog\n // or announce that it has opened until it has rendered. A workaround\n // is to wait for half a second, then blur and re-focus the dialog.\n let timeout = setTimeout(() => {\n // Check that the dialog is still focused, or focused was lost to the body.\n if (document.activeElement === ref.current || document.activeElement === document.body) {\n isRefocusing.current = true;\n if (ref.current) {\n ref.current.blur();\n focusSafely(ref.current);\n }\n isRefocusing.current = false;\n }\n }, 500);\n\n return () => {\n clearTimeout(timeout);\n };\n }\n }, [ref]);\n\n useOverlayFocusContain();\n\n // We do not use aria-modal due to a Safari bug which forces the first focusable element to be focused\n // on mount when inside an iframe, no matter which element we programmatically focus.\n // See https://bugs.webkit.org/show_bug.cgi?id=211934.\n // useModal sets aria-hidden on all elements outside the dialog, so the dialog will behave as a modal\n // even without aria-modal on the dialog itself.\n return {\n dialogProps: {\n ...filterDOMProps(props, {labelable: true}),\n role,\n tabIndex: -1,\n 'aria-labelledby': props['aria-labelledby'] || titleId,\n // Prevent blur events from reaching useOverlay, which may cause\n // popovers to close. Since focus is contained within the dialog,\n // we don't want this to occur due to the above useEffect.\n onBlur: e => {\n if (isRefocusing.current) {\n e.stopPropagation();\n }\n }\n },\n titleProps: {\n id: titleId\n }\n };\n}\n"],"names":[],"version":3,"file":"useDialog.main.js.map"}
@@ -30,7 +30,8 @@ function $40df3f8667284809$export$d55e7ee900f34e93(props, ref) {
30
30
  // or announce that it has opened until it has rendered. A workaround
31
31
  // is to wait for half a second, then blur and re-focus the dialog.
32
32
  let timeout = setTimeout(()=>{
33
- if (document.activeElement === ref.current) {
33
+ // Check that the dialog is still focused, or focused was lost to the body.
34
+ if (document.activeElement === ref.current || document.activeElement === document.body) {
34
35
  isRefocusing.current = true;
35
36
  if (ref.current) {
36
37
  ref.current.blur();
@@ -30,7 +30,8 @@ function $40df3f8667284809$export$d55e7ee900f34e93(props, ref) {
30
30
  // or announce that it has opened until it has rendered. A workaround
31
31
  // is to wait for half a second, then blur and re-focus the dialog.
32
32
  let timeout = setTimeout(()=>{
33
- if (document.activeElement === ref.current) {
33
+ // Check that the dialog is still focused, or focused was lost to the body.
34
+ if (document.activeElement === ref.current || document.activeElement === document.body) {
34
35
  isRefocusing.current = true;
35
36
  if (ref.current) {
36
37
  ref.current.blur();
@@ -1 +1 @@
1
- {"mappings":";;;;;AAAA;;;;;;;;;;CAUC;;;;AAqBM,SAAS,0CAAU,KAAsB,EAAE,GAAuC;IACvF,IAAI,QACF,OAAO,UACR,GAAG;IACJ,IAAI,UAA8B,CAAA,GAAA,gBAAQ;IAC1C,UAAU,KAAK,CAAC,aAAa,GAAG,YAAY;IAE5C,IAAI,eAAe,CAAA,GAAA,aAAK,EAAE;IAE1B,+EAA+E;IAC/E,CAAA,GAAA,gBAAQ,EAAE;QACR,IAAI,IAAI,OAAO,IAAI,CAAC,IAAI,OAAO,CAAC,QAAQ,CAAC,SAAS,aAAa,GAAG;YAChE,CAAA,GAAA,kBAAU,EAAE,IAAI,OAAO;YAEvB,iEAAiE;YACjE,qEAAqE;YACrE,mEAAmE;YACnE,IAAI,UAAU,WAAW;gBACvB,IAAI,SAAS,aAAa,KAAK,IAAI,OAAO,EAAE;oBAC1C,aAAa,OAAO,GAAG;oBACvB,IAAI,IAAI,OAAO,EAAE;wBACf,IAAI,OAAO,CAAC,IAAI;wBAChB,CAAA,GAAA,kBAAU,EAAE,IAAI,OAAO;oBACzB;oBACA,aAAa,OAAO,GAAG;gBACzB;YACF,GAAG;YAEH,OAAO;gBACL,aAAa;YACf;QACF;IACF,GAAG;QAAC;KAAI;IAER,CAAA,GAAA,6BAAqB;IAErB,sGAAsG;IACtG,qFAAqF;IACrF,sDAAsD;IACtD,qGAAqG;IACrG,gDAAgD;IAChD,OAAO;QACL,aAAa;YACX,GAAG,CAAA,GAAA,qBAAa,EAAE,OAAO;gBAAC,WAAW;YAAI,EAAE;kBAC3C;YACA,UAAU;YACV,mBAAmB,KAAK,CAAC,kBAAkB,IAAI;YAC/C,gEAAgE;YAChE,iEAAiE;YACjE,0DAA0D;YAC1D,QAAQ,CAAA;gBACN,IAAI,aAAa,OAAO,EACtB,EAAE,eAAe;YAErB;QACF;QACA,YAAY;YACV,IAAI;QACN;IACF;AACF","sources":["packages/@react-aria/dialog/src/useDialog.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaDialogProps} from '@react-types/dialog';\nimport {DOMAttributes, FocusableElement, RefObject} from '@react-types/shared';\nimport {filterDOMProps, useSlotId} from '@react-aria/utils';\nimport {focusSafely} from '@react-aria/interactions';\nimport {useEffect, useRef} from 'react';\nimport {useOverlayFocusContain} from '@react-aria/overlays';\n\nexport interface DialogAria {\n /** Props for the dialog container element. */\n dialogProps: DOMAttributes,\n\n /** Props for the dialog title element. */\n titleProps: DOMAttributes\n}\n\n/**\n * Provides the behavior and accessibility implementation for a dialog component.\n * A dialog is an overlay shown above other content in an application.\n */\nexport function useDialog(props: AriaDialogProps, ref: RefObject<FocusableElement | null>): DialogAria {\n let {\n role = 'dialog'\n } = props;\n let titleId: string | undefined = useSlotId();\n titleId = props['aria-label'] ? undefined : titleId;\n\n let isRefocusing = useRef(false);\n\n // Focus the dialog itself on mount, unless a child element is already focused.\n useEffect(() => {\n if (ref.current && !ref.current.contains(document.activeElement)) {\n focusSafely(ref.current);\n\n // Safari on iOS does not move the VoiceOver cursor to the dialog\n // or announce that it has opened until it has rendered. A workaround\n // is to wait for half a second, then blur and re-focus the dialog.\n let timeout = setTimeout(() => {\n if (document.activeElement === ref.current) {\n isRefocusing.current = true;\n if (ref.current) {\n ref.current.blur();\n focusSafely(ref.current);\n }\n isRefocusing.current = false;\n }\n }, 500);\n\n return () => {\n clearTimeout(timeout);\n };\n }\n }, [ref]);\n\n useOverlayFocusContain();\n\n // We do not use aria-modal due to a Safari bug which forces the first focusable element to be focused\n // on mount when inside an iframe, no matter which element we programmatically focus.\n // See https://bugs.webkit.org/show_bug.cgi?id=211934.\n // useModal sets aria-hidden on all elements outside the dialog, so the dialog will behave as a modal\n // even without aria-modal on the dialog itself.\n return {\n dialogProps: {\n ...filterDOMProps(props, {labelable: true}),\n role,\n tabIndex: -1,\n 'aria-labelledby': props['aria-labelledby'] || titleId,\n // Prevent blur events from reaching useOverlay, which may cause\n // popovers to close. Since focus is contained within the dialog,\n // we don't want this to occur due to the above useEffect.\n onBlur: e => {\n if (isRefocusing.current) {\n e.stopPropagation();\n }\n }\n },\n titleProps: {\n id: titleId\n }\n };\n}\n"],"names":[],"version":3,"file":"useDialog.module.js.map"}
1
+ {"mappings":";;;;;AAAA;;;;;;;;;;CAUC;;;;AAqBM,SAAS,0CAAU,KAAsB,EAAE,GAAuC;IACvF,IAAI,QACF,OAAO,UACR,GAAG;IACJ,IAAI,UAA8B,CAAA,GAAA,gBAAQ;IAC1C,UAAU,KAAK,CAAC,aAAa,GAAG,YAAY;IAE5C,IAAI,eAAe,CAAA,GAAA,aAAK,EAAE;IAE1B,+EAA+E;IAC/E,CAAA,GAAA,gBAAQ,EAAE;QACR,IAAI,IAAI,OAAO,IAAI,CAAC,IAAI,OAAO,CAAC,QAAQ,CAAC,SAAS,aAAa,GAAG;YAChE,CAAA,GAAA,kBAAU,EAAE,IAAI,OAAO;YAEvB,iEAAiE;YACjE,qEAAqE;YACrE,mEAAmE;YACnE,IAAI,UAAU,WAAW;gBACvB,2EAA2E;gBAC3E,IAAI,SAAS,aAAa,KAAK,IAAI,OAAO,IAAI,SAAS,aAAa,KAAK,SAAS,IAAI,EAAE;oBACtF,aAAa,OAAO,GAAG;oBACvB,IAAI,IAAI,OAAO,EAAE;wBACf,IAAI,OAAO,CAAC,IAAI;wBAChB,CAAA,GAAA,kBAAU,EAAE,IAAI,OAAO;oBACzB;oBACA,aAAa,OAAO,GAAG;gBACzB;YACF,GAAG;YAEH,OAAO;gBACL,aAAa;YACf;QACF;IACF,GAAG;QAAC;KAAI;IAER,CAAA,GAAA,6BAAqB;IAErB,sGAAsG;IACtG,qFAAqF;IACrF,sDAAsD;IACtD,qGAAqG;IACrG,gDAAgD;IAChD,OAAO;QACL,aAAa;YACX,GAAG,CAAA,GAAA,qBAAa,EAAE,OAAO;gBAAC,WAAW;YAAI,EAAE;kBAC3C;YACA,UAAU;YACV,mBAAmB,KAAK,CAAC,kBAAkB,IAAI;YAC/C,gEAAgE;YAChE,iEAAiE;YACjE,0DAA0D;YAC1D,QAAQ,CAAA;gBACN,IAAI,aAAa,OAAO,EACtB,EAAE,eAAe;YAErB;QACF;QACA,YAAY;YACV,IAAI;QACN;IACF;AACF","sources":["packages/@react-aria/dialog/src/useDialog.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaDialogProps} from '@react-types/dialog';\nimport {DOMAttributes, FocusableElement, RefObject} from '@react-types/shared';\nimport {filterDOMProps, useSlotId} from '@react-aria/utils';\nimport {focusSafely} from '@react-aria/interactions';\nimport {useEffect, useRef} from 'react';\nimport {useOverlayFocusContain} from '@react-aria/overlays';\n\nexport interface DialogAria {\n /** Props for the dialog container element. */\n dialogProps: DOMAttributes,\n\n /** Props for the dialog title element. */\n titleProps: DOMAttributes\n}\n\n/**\n * Provides the behavior and accessibility implementation for a dialog component.\n * A dialog is an overlay shown above other content in an application.\n */\nexport function useDialog(props: AriaDialogProps, ref: RefObject<FocusableElement | null>): DialogAria {\n let {\n role = 'dialog'\n } = props;\n let titleId: string | undefined = useSlotId();\n titleId = props['aria-label'] ? undefined : titleId;\n\n let isRefocusing = useRef(false);\n\n // Focus the dialog itself on mount, unless a child element is already focused.\n useEffect(() => {\n if (ref.current && !ref.current.contains(document.activeElement)) {\n focusSafely(ref.current);\n\n // Safari on iOS does not move the VoiceOver cursor to the dialog\n // or announce that it has opened until it has rendered. A workaround\n // is to wait for half a second, then blur and re-focus the dialog.\n let timeout = setTimeout(() => {\n // Check that the dialog is still focused, or focused was lost to the body.\n if (document.activeElement === ref.current || document.activeElement === document.body) {\n isRefocusing.current = true;\n if (ref.current) {\n ref.current.blur();\n focusSafely(ref.current);\n }\n isRefocusing.current = false;\n }\n }, 500);\n\n return () => {\n clearTimeout(timeout);\n };\n }\n }, [ref]);\n\n useOverlayFocusContain();\n\n // We do not use aria-modal due to a Safari bug which forces the first focusable element to be focused\n // on mount when inside an iframe, no matter which element we programmatically focus.\n // See https://bugs.webkit.org/show_bug.cgi?id=211934.\n // useModal sets aria-hidden on all elements outside the dialog, so the dialog will behave as a modal\n // even without aria-modal on the dialog itself.\n return {\n dialogProps: {\n ...filterDOMProps(props, {labelable: true}),\n role,\n tabIndex: -1,\n 'aria-labelledby': props['aria-labelledby'] || titleId,\n // Prevent blur events from reaching useOverlay, which may cause\n // popovers to close. Since focus is contained within the dialog,\n // we don't want this to occur due to the above useEffect.\n onBlur: e => {\n if (isRefocusing.current) {\n e.stopPropagation();\n }\n }\n },\n titleProps: {\n id: titleId\n }\n };\n}\n"],"names":[],"version":3,"file":"useDialog.module.js.map"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-aria/dialog",
3
- "version": "3.5.27",
3
+ "version": "3.5.29",
4
4
  "description": "Spectrum UI components in React",
5
5
  "license": "Apache-2.0",
6
6
  "main": "dist/main.js",
@@ -30,15 +30,15 @@
30
30
  "react-dom": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1"
31
31
  },
32
32
  "dependencies": {
33
- "@react-aria/interactions": "^3.25.3",
34
- "@react-aria/overlays": "^3.27.3",
35
- "@react-aria/utils": "^3.29.1",
36
- "@react-types/dialog": "^3.5.19",
37
- "@react-types/shared": "^3.30.0",
33
+ "@react-aria/interactions": "^3.25.5",
34
+ "@react-aria/overlays": "^3.29.0",
35
+ "@react-aria/utils": "^3.30.1",
36
+ "@react-types/dialog": "^3.5.21",
37
+ "@react-types/shared": "^3.32.0",
38
38
  "@swc/helpers": "^0.5.0"
39
39
  },
40
40
  "publishConfig": {
41
41
  "access": "public"
42
42
  },
43
- "gitHead": "a063122082d2b372e4846b58c85ae69ec73887ff"
43
+ "gitHead": "2c58ed3ddd9be9100af9b1d0cfd137fcdc95ba2d"
44
44
  }
package/src/useDialog.ts CHANGED
@@ -47,7 +47,8 @@ export function useDialog(props: AriaDialogProps, ref: RefObject<FocusableElemen
47
47
  // or announce that it has opened until it has rendered. A workaround
48
48
  // is to wait for half a second, then blur and re-focus the dialog.
49
49
  let timeout = setTimeout(() => {
50
- if (document.activeElement === ref.current) {
50
+ // Check that the dialog is still focused, or focused was lost to the body.
51
+ if (document.activeElement === ref.current || document.activeElement === document.body) {
51
52
  isRefocusing.current = true;
52
53
  if (ref.current) {
53
54
  ref.current.blur();