nextui icon indicating copy to clipboard operation
nextui copied to clipboard

[BUG] - Backdrop blur being applied on animation end

Open simonetimi opened this issue 1 year ago • 8 comments

NextUI Version

2.4.2

Describe the bug

On the Dropdown component, applying a custom background works as expected. However, when applying a tailwind class like backdrop-blur-lg, the effect is applied only at the end of the opening animation, unlike other classes like bg-color.

In my case, I'm trying to make the style consistent with the rest of the UI. Having some semi-transparent UI elements, blur is necessary to keep the text readable. Having it switch to blur only after the animation ends makes it unpleasant. For now I'm disabling the animation but it's obviously not ideal.

Your Example Website or App

No response

Steps to Reproduce the Bug or Issue

  1. Add backdrop blur tailwind class to a Dropdown component
  2. Click on the dropdown trigger

JSX code in client component

<Dropdown
    className="bg-white/40 backdrop-blur-lg dark:bg-black/40"
>
    <DropdownTrigger>
        <Button isIconOnly className="bg-transparent" disableRipple>
            <EllipsisVerticalIcon width={20} />
        </Button>
    </DropdownTrigger>
    <DropdownMenu aria-label="Todo Actions">
        <DropdownItem key="details" onPress={onOpen}>
            Show details
        </DropdownItem>
        <DropdownItem key="edit">Edit</DropdownItem>
        <DropdownItem
            key="delete"
            className="text-danger"
            color="danger"
        >
            Delete
        </DropdownItem>
    </DropdownMenu>
</Dropdown>

Expected behavior

The blur effect should be displayed consistently with the other styles, at the beginning of the animation.

Screenshots or Videos

During the animation

Screenshot 2024-07-16 alle 13 09 18

After the animation

Screenshot 2024-07-16 alle 13 09 27

Operating System Version

macOS

Browser

Chrome

simonetimi avatar Jul 16 '24 11:07 simonetimi

there is a property in dropdown called backdrop , in which you can select blur option it doesn't have the animation problem but blurs out the background too

Tejas-Sands avatar Jul 17 '24 09:07 Tejas-Sands

there is a property in dropdown called backdrop , in which you can select blur option it doesn't have the animation problem but blurs out the background too

That option will have an effect on the whole page (expect for the menu), I'm looking for the exact opposite (I need the menu background to be blurred). So far I can either use a solid background (which unfortunately doesn't match with the rest of the UI) or disable the animation.

simonetimi avatar Jul 17 '24 09:07 simonetimi

I think this problem occurs because backdrop property is added in pop over prop Instead it should have been added to the menu prop

Tejas-Sands avatar Jul 17 '24 10:07 Tejas-Sands

@simonetimi can you minimal reproducible enviroment like CodeSankBox or StackBlitz

awesome-pro avatar Jul 19 '24 23:07 awesome-pro

@simonetimi can you minimal reproducible enviroment like CodeSankBox or StackBlitz

I set it up on StackBlitz: sandbox

I put some text underneath. When clicking the button, the blur on the menu bg will show only when the animation ends. The sandbox doesn't work for me in Safari for some reason, but this bug is not present in safari anyway.

simonetimi avatar Jul 20 '24 07:07 simonetimi

@simonetimi I observed you issue, the effect is visible in Chrome and Firefox but not in safari . I am working on it and will help you soon

awesome-pro avatar Jul 25 '24 04:07 awesome-pro

any updates?

ritik3236 avatar Oct 10 '24 20:10 ritik3236

6 months, 1 week and 2 days passed still no update ?

ritik3236 avatar Jan 20 '25 22:01 ritik3236

Mark, wait for updates

amandakelake avatar Mar 16 '25 09:03 amandakelake

yeah the reason why is because of the animation from framer-motion.

So to fix this, pass the motion props and add the backdrop-blur style to it like this:

<Dropdown motionProps={{
                    style: {
                        backdropFilter: "blur(var(--blur-lg)) saturate(150%)",
                        borderRadius: "var(--radius-xl)",
                    }
                }}
... rest of your code

OR, just put disableAnimation prop on your dropdown.

kzroo avatar Jun 21 '25 06:06 kzroo