-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature Request] Allow disabling of focus trap in modal #2175
Comments
Also in Drawer, please 😢 . It's very intrusive when embedding the page in an iframe. |
Have you found any solution for this ? |
no 😔 |
I have a similar case using Spreedly fields (iframes), while those are inside the Modal we can't tab into them, but we can tab out of them back to the modal. This feature would help use alot. I think this is somehow related to #3204 and @wingkwong |
@ArielBenichou I can supplement a bit. For the issue you linked, it was just fixing the expected behaviour. By design, focus trap is applied when the modal is open, previously I applied This issue is a bit tricky because the focus trap logic comes from the RA dependencies. We can disable the focus management by passing |
@wingkwong I'm not well versed in NextUI code to argue otherwise. I don't like to Hacky SolutionIf anyone needs it
Note: I've only taken the minimum changes from the diff --git a/node_modules/@nextui-org/modal/dist/chunk-X4CB5I5S.mjs b/node_modules/@nextui-org/modal/dist/chunk-X4CB5I5S.mjs
index b6a8fb6..4ee537f 100644
--- a/node_modules/@nextui-org/modal/dist/chunk-X4CB5I5S.mjs
+++ b/node_modules/@nextui-org/modal/dist/chunk-X4CB5I5S.mjs
@@ -12,9 +12,9 @@ import { Overlay } from "@react-aria/overlays";
import { forwardRef } from "@nextui-org/system";
import { jsx } from "react/jsx-runtime";
var Modal = forwardRef((props, ref) => {
- const { children, ...otherProps } = props;
+ const { children, disableFocusManagement, ...otherProps } = props;
const context = useModal({ ...otherProps, ref });
- const overlay = /* @__PURE__ */ jsx(Overlay, { portalContainer: context.portalContainer, children });
+ const overlay = /* @__PURE__ */ jsx(Overlay, { disableFocusManagement: Boolean(disableFocusManagement), portalContainer: context.portalContainer, children });
return /* @__PURE__ */ jsx(ModalProvider, { value: context, children: context.disableAnimation && context.isOpen ? overlay : /* @__PURE__ */ jsx(AnimatePresence, { children: context.isOpen ? overlay : null }) });
});
Modal.displayName = "NextUI.Modal";
diff --git a/node_modules/@nextui-org/modal/dist/modal.d.ts b/node_modules/@nextui-org/modal/dist/modal.d.ts
index 7943946..51887b2 100644
--- a/node_modules/@nextui-org/modal/dist/modal.d.ts
+++ b/node_modules/@nextui-org/modal/dist/modal.d.ts
@@ -9,10 +9,11 @@ import '@nextui-org/react-utils';
import '@react-stately/overlays';
interface ModalProps extends UseModalProps {
- /**
- * The content of the modal. Usually the ModalContent
- */
- children: ReactNode;
+ /**
+ * The content of the modal. Usually the ModalContent
+ */
+ children: ReactNode;
+ disableFocusManagement?: boolean;
}
declare const Modal: _nextui_org_system.InternalForwardRefRenderFunction<"div", ModalProps, never>;
diff --git a/node_modules/@nextui-org/modal/dist/modal.js b/node_modules/@nextui-org/modal/dist/modal.js
index ecf5967..769c4e8 100644
--- a/node_modules/@nextui-org/modal/dist/modal.js
+++ b/node_modules/@nextui-org/modal/dist/modal.js
@@ -162,9 +164,9 @@ var [ModalProvider, useModalContext] = (0, import_react_utils2.createContext)({
// src/modal.tsx
var import_jsx_runtime = require("react/jsx-runtime");
var Modal = (0, import_system2.forwardRef)((props, ref) => {
- const { children, ...otherProps } = props;
+ const { children, disableFocusManagement, ...otherProps } = props;
const context = useModal({ ...otherProps, ref });
- const overlay = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_overlays2.Overlay, { portalContainer: context.portalContainer, children });
+ const overlay = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_overlays2.Overlay, { disableFocusManagement: Boolean(disableFocusManagement), portalContainer: context.portalContainer, children });
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ModalProvider, { value: context, children: context.disableAnimation && context.isOpen ? overlay : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_framer_motion.AnimatePresence, { children: context.isOpen ? overlay : null }) });
});
Modal.displayName = "NextUI.Modal"; |
Is there a way to globally disable |
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
Is your feature request related to a problem? Please describe.
We are using Usersnap on our website to have users notify us of issues they have. When a modal is opened, it is not possible click into any of the usersnap input-fields. I believe this is because a focustrap is available on the Modal, because of this rule:
Which is obviously a great feature, but it also would be very useful to have an escape-hatch to disable this functionality when we see that the usersnap-window is open.
Describe the solution you'd like
It would be preferred to have a
disableFocusTrap
-flag on the Modal or something to be able to opt-out of this functionality.Describe alternatives you've considered
I've looked for options available in the Modal-component, but there does not seem to be a way to work around this.
Screenshots or Videos
No response
The text was updated successfully, but these errors were encountered: