Skip to content
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

Dropdown menu doesn't work with fallback avatar #2821

Open
bertbarabas opened this issue Mar 9, 2024 · 1 comment
Open

Dropdown menu doesn't work with fallback avatar #2821

bertbarabas opened this issue Mar 9, 2024 · 1 comment
Labels
components bug a bug in a specific component linear Created by Linear-GitHub Sync OSS Bug Created by Linear-GitHub Sync workaround available

Comments

@bertbarabas
Copy link

Describe the bug
A dropdown menu with an Avatar as the trigger works only if the Avatar was given a proper image and the fallback was not used. If the fallback is used, the dropdown menu no longer responds to being clicked on.

To Reproduce
Steps to reproduce the behavior:

def extract_initials_from_email(email):
    name = email.split("@")[0]
    initials = "".join(c[0] for c in name.split(".") if c.isalpha())
    return initials[:2].upper()


def account_drop_down() -> rx.Component:
    email = "[email protected]"
    initials = extract_initials_from_email(email)
    g = Gravatar(email)
    img = g.get_image(default="404")
    avatar = rx.avatar(src=img, fallback=initials, radius="full")

    return rx.menu.root(
        rx.menu.trigger(avatar),
        rx.menu.content(
            rx.menu.separator(),
            rx.menu.item("Logout", color="red", on_click=rx.console_log(img)),
        ),
        position="fixed",
        right="1.5em",
        top="1.5em",
    )

Expected behavior
The dropdown should appear regardless if the avatar has an image or if it has the fallback text

Screenshots
Here you can see clicking on the avatar brings up the drop down menu:
image

And here you can see when clicked on the avatar with the fallback text does not show the drop down menu:
image

Specifics (please complete the following information):

  • Python Version: 3.12.1
  • Reflex Version: 0.4.3
  • OS: OS: WSL on Windows 11 (Ubuntu 22.04.4 LTS (GNU/Linux 5.15.133.1-microsoft-standard-WSL2 x86_64)
  • Browser (Optional):

Additional context
Add any other context about the problem here.

@Alek99 Alek99 added the bug Something isn't working label Mar 11, 2024
@ElijahAhianyo ElijahAhianyo added linear Created by Linear-GitHub Sync OSS Bug Created by Linear-GitHub Sync labels Mar 27, 2024
@boterop
Copy link
Contributor

boterop commented Oct 5, 2024

@bertbarabas till it is fixed, you can surround it with flex.

def extract_initials_from_email(email):
    name = email.split("@")[0]
    initials = "".join(c[0] for c in name.split(".") if c.isalpha())
    return initials[:2].upper()


def account_drop_down() -> rx.Component:
    email = "[email protected]"
    initials = extract_initials_from_email(email)
    g = Gravatar(email)
    img = g.get_image(default="404")
    avatar = rx.avatar(src=img, fallback=initials, radius="full")

    return rx.menu.root(
-       rx.menu.trigger(avatar),
+       rx.menu.trigger(rx.flex(avatar)),
        rx.menu.content(
            rx.menu.separator(),
            rx.menu.item("Logout", color="red", on_click=rx.console_log(img)),
        ),
        position="fixed",
        right="1.5em",
        top="1.5em",
    )

@adhami3310 adhami3310 added workaround available components bug a bug in a specific component and removed bug Something isn't working hacktoberfest labels Feb 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
components bug a bug in a specific component linear Created by Linear-GitHub Sync OSS Bug Created by Linear-GitHub Sync workaround available
Projects
None yet
Development

No branches or pull requests

6 participants