nextui icon indicating copy to clipboard operation
nextui copied to clipboard

[BUG] - Using Tabs inside Modal breaks UI

Open jrmylee opened this issue 1 year ago โ€ข 20 comments

HeroUI Version

2.6.14

Describe the bug

When a Modal containing Tabs is closed after switching between tabs, the modal's content remains visually present on the screen but in a "ghosted" state. This creates a UI layer that appears invisible but still occupies space and interferes with user interactions, as clicks are being intercepted by the invisible modal content.

Your Example Website or App

No response

Steps to Reproduce the Bug or Issue

Reproducible steps:

  • Add 2 tabs inside a modal content component
  • Open modal
  • If tab 1 is selected, switch to tab 2
  • Close modal
  • The contents of the modal will still be on the screen, but not rendered(ghosted). So nothing will be clickable to the user, because the user is clicking the contents of the modal without knowing it.

Expected behavior

When the modal is closed, all of its content, including any tab components and their associated content, should be completely removed from both the DOM and visual layer. There should be no residual UI elements or invisible interactive areas remaining after the modal is closed.

Screenshots or Videos

No response

Operating System Version

macOS

Browser

Chrome

jrmylee avatar Feb 06 '25 23:02 jrmylee

I couldn't reproduce the issue. Please share a sandbox.

https://github.com/user-attachments/assets/9dcbba58-4a1a-4dbd-88a0-d0903778ff97

wingkwong avatar Feb 09 '25 07:02 wingkwong

I also got the same error

congnt148 avatar Feb 09 '25 15:02 congnt148

I also got the same problem. Changing to the second tab and closing the modal make other elements unclickable. I noticed that the div opened for the modal in the react portal stays there even if the modal is closed.

4Furki4 avatar Feb 11 '25 10:02 4Furki4

Here is a reproduction of the issue

Fresh demo with react-router-v7, of course the UI is broken because of tailwind 4, but that's another issue.

In our app, we are still on tailwind 3, the bug with Modal was found when upgrading from Remix 2 to react-router-v7.

Video :

https://github.com/user-attachments/assets/ac9f3234-4b64-482e-bf95-0d4f9a2b3f34

jmvie5 avatar Feb 11 '25 18:02 jmvie5

I'm having the same problem and I think the internal components should be cleared after the Model is closed.

kulovecc avatar Feb 19 '25 06:02 kulovecc

I also encountered the same problem, when using tab in Modal, after clicking the tab operation, closing modal could not be clicked

djmpink avatar Feb 27 '25 01:02 djmpink

I am currently experiencing the same issue.

musab-olurode avatar Mar 13 '25 12:03 musab-olurode

another repo: https://heroui.chat/chat/4baad63f-3dbc-454d-a52a-5bbaccdcf010

wingkwong avatar Mar 20 '25 11:03 wingkwong

another repo: https://heroui.chat/chat/4baad63f-3dbc-454d-a52a-5bbaccdcf010

aha that one made by me, this is a description I made for the issue ๐Ÿ‘‰

I found an issue with using tabs inside modal, when I use Tabs component inside Modal and change tabs then closes the modal ( even by clicking outside it or close icon ) and try to click on any button in the UI it doesn't action, I made an example for the issue here ๐Ÿ‘‰ https://heroui.app/BGewXad, after some debugging, I found that the div with data-overlay-container=true doesn't hide when modal closes. but couldn't find out how to hide it as expected!

Ahmed3tef avatar Mar 20 '25 11:03 Ahmed3tef

Hi. I'm facing the same issue after updating to 2.7.5. In addition to this issue, I realized that the Tab loses all of it's animations. I found a workaround changing the motion props:

export const MOTION_PROPS = {
  variants: {
    enter: {
      scale: 1,
      y: 'var(--slide-enter)',
      opacity: 1,
      transition: {
        scale: {
          duration: 0.4,
          ease: TRANSITION_EASINGS.ease
        },
        opacity: {
          duration: 0.4,
          ease: TRANSITION_EASINGS.ease
        },
        y: {
          type: 'spring',
          bounce: 0,
          duration: 0.6
        }
      }
    },
    exit: {
      scale: 1.1, // NextUI default 1.03
      y: 'var(--slide-exit)',
      opacity: 0,
      transition: {
        duration: 0.3,
        ease: TRANSITION_EASINGS.ease
      }
    }
  }
}

And using the new props on the Tabs component:

<Modal
      scrollBehavior='inside'
      shouldBlockScroll
      isOpen={isOpen}
      motionProps={MOTION_PROPS }
      onOpenChange={onOpenChange}
      size='lg'
    >
       <ModalContent className='min-h-[600px]'>
          <ModalHeader className='flex items-center gap-2'>
            <BsPeople size={18}/> {__('Gestiรณn de candidatos')}
          </ModalHeader>
          <ModalBody>
             <Tabs
                  variant='underlined'
                  color='primary'
                  [...]

I forked the example you provided and added the workaround:

https://heroui.app/VjTNqLG

Hope it helps.

jonathanhirint avatar Mar 21 '25 08:03 jonathanhirint

Downgrading framer-motion to 11.16.7 would also fix the issue. In fact, currently we are using 11.9.0. Using higher version may cause unexpected issues.

wingkwong avatar Mar 29 '25 11:03 wingkwong

Fixes provided by @jonathanhirint and @wingkwong do not work for me on macOS 15.3.2 tried on Firefox and Chrome.

jmvie5 avatar Mar 29 '25 13:03 jmvie5

Hope to fix this problem soon.

djmpink avatar Apr 03 '25 06:04 djmpink

Downgrading framer-motion to 11.16.7 would also fix the issue. In fact, currently we are using 11.9.0. Using higher version may cause unexpected issues.

Thanks @wingkwong I downgraded to 11.16.7 and it worked for me but i think we still need a fix for this

Kirolos-kr7 avatar Apr 03 '25 13:04 Kirolos-kr7

We are experiencing the same issue with modals when using tabs inside them. Unfortunately, downgrading framer-motion did not resolve the problem. Any suggestions or updates on this would be greatly appreciated.

WhatzzUp avatar Apr 24 '25 10:04 WhatzzUp

We're having the same issue

201549BL avatar Apr 24 '25 12:04 201549BL

+1

jatin127 avatar Apr 25 '25 12:04 jatin127

The fix is now available in beta version for 2.8.0.

wingkwong avatar May 28 '25 16:05 wingkwong

The fix is now available in beta version for 2.8.0.

I tried beta7 and 6 and still not working

edit: updating framer-motion to 12.16.0 worked but i have to try this on apple products

pablojsx avatar Jun 10 '25 05:06 pablojsx