-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
[BUG] - Modal does not adjust position when keyboard appears on iOS #2837
Comments
@jalvarezz13 can you attach a screenshot and some code? Also can you share how it looked in 2.2.x? |
The code could be this modal https://nextui.org/docs/components/modal#with-form without "top-center" placement. ios.mp4 |
Facing the same issue after bumping to 2.3.5. Seems like a regression, everything worked just fine before update. |
Im facing the same issue |
Can also reproduce |
Looks like it's somehow related to the internal implementation of the scroll-blocking behavior within Modal const ModalTemplate = <ContentWrapperProps extends TContentWrapperProps, ModalFooterProps extends TModalFooterProps>({ title, children, ModalContentWrapper = Fragment, modalContentWrapperProps, ModalFooter, getModalFooterProps, isLoading, ...modalProps }: IModalTemplateProps<ContentWrapperProps, ModalFooterProps>): ReactElement => {
const scrollableTargetRef = useRef<HTMLDivElement>(null);
useEffect(
(): void => {
if (modalProps.isOpen && scrollableTargetRef.current) {
disableBodyScroll(scrollableTargetRef.current);
return;
}
clearAllBodyScrollLocks();
},
[modalProps.isOpen],
);
return (
<Modal
size="2xl"
backdrop="blur"
scrollBehavior="inside"
hideCloseButton
shouldBlockScroll={false}
classNames={{
backdrop: 'top-0 left-0',
}}
{...modalProps}
>
<ModalContent>
{(close: () => void): ReactElement => (
<ModalContentWrapper
{...modalContentWrapperProps as ContentWrapperProps}
className="[display:contents]"
>
<ModalHeader className="flex flex-col gap-1">
<div className="flex w-full items-center justify-between gap-2">
{title}
<Button
variant="light"
isIconOnly
onPress={close}
>
<CloseIcon />
</Button>
</div>
</ModalHeader>
/** Explicit <ModalBody /> implementation. class names list was taken from nextui.Modal.ModalBody as is **/
<div
className="flex flex-1 flex-col gap-3 overflow-y-auto px-6 py-2"
ref={scrollableTargetRef}
>
{children}
</div>
{ModalFooter && (
<ModalFooterBase>
<ModalFooter
{...(typeof getModalFooterProps === 'function' && getModalFooterProps({
close,
isLoading,
})) as ModalFooterProps}
/>
</ModalFooterBase>
)}
</ModalContentWrapper>
)}
</ModalContent>
</Modal>
);
};
export default ModalTemplate;
|
same issue with 2.3.6 |
Any update? Thanks! |
In case it helps... I'm temporarily using @nextui-org/modal in version 2.0.29 until this bug is fixed. |
@jrgarciadev The error persists in version 2.4.0 |
i'm having the same problem, does anyone have an idea on how to fix it? |
Just use the version of the modal from further up where it works. Install just the individual modal package version above and import the modal from that package instead of the central package |
Same issue with version 2.0.36 of modal. |
@kamami If you want to fix this issue, you can install the individual modal box using version 2.0.0. It is a little bit buggy too, but the keyboard issue does not occur in this version. However, in other versions, the keyboard hides the inputs in all versions. |
@theonlyway thanks! I also just kept the latest version and on mobile screens i adjusted the absolute position as others suggested here. |
same issue here, installing @nextui-org/modal@2.0.0 works for now |
Oof. 2.0.0 fixes this, but scrolling is broken even with scrollBehavior outside if the modal is too big... ruh roh. EDIT: For scrollBehavior: outside to work you also need placement set to top.... hmm |
|
any update? :( |
+1 |
any fixes, updates? |
It's been almost 4 months since the bug appeared, and no one from the NextUI organization seems to have addressed it in this thread. For those who cannot do the same, I recommend installing the NextUI modal component in isolation from the rest. Also, remember to install the following dependencies to avoid potential issues:
You can install them with: |
I found a solution with css, tested it and it seems to work reasonably, hope it helps too.
Usage example
|
I had to use |
@wingkwong I see you have self-assigned this issue, are you working on a specific branch you can share? Thanks |
@cristyz Thank you for sharing the temporal solution, it's not working for my specific use case but it's a good solution for other cases :) |
I have managed to avoid this by using an external library, which is not ideal, but will do for now. https://www.npmjs.com/package/use-detect-keyboard-open
|
Any update or release plz? |
Any updates? |
I've made the PR, which is currently under review. |
Thank you so much @wingkwong... I can't wait to see it at the release! |
For those who need the fix before the next bug fix release (v.2.4.7), you may use the canary version for the time being (i.e. change the version to |
This version crash the autocomplete. Any spected date to this new full release? |
@daniel-esserweb I recently also noticed that. I may rollback autocomplete change first. |
@daniel-esserweb just rollbacked the change and released another canary version. The full release should be available in weekend (tentatively). |
fixed or news?.. :) |
@HastaCs already included in the latest version. |
NextUI Version
2.3.5
Describe the bug
After updating from version 2.2.X to 2.3.X, there is an issue observed on iOS devices where the modal dialog does not adjust its position when the keyboard appears on the screen. As a result, the modal remains in its original position, obscuring the view of the input fields and preventing users from seeing what they are typing. This behavior affects the usability of the application, especially in forms and dialogs requiring user input.
Your Example Website or App
No response
Steps to Reproduce the Bug or Issue
Notice that when the keyboard appears, the modal remains in its fixed position at the bottom of the screen. The keyboard covers the modal, obscuring the input field and preventing the user from seeing what is being typed.
Expected behavior
The modal should adjust its position when the keyboard appears, moving up to ensure that the input field is visible and the user can see what they are typing.
Screenshots or Videos
No response
Operating System Version
iOS 17.4.1
Browser
Safari
The text was updated successfully, but these errors were encountered: