Code Monkey home page Code Monkey logo

Comments (7)

vladmoroz avatar vladmoroz commented on May 26, 2024

Can you clarify the issue with an example? In Radix Themes the Dropdown Menu Content component already comes with a built-in Scroll Area:

Screen.Recording.2023-10-06.at.11.12.16.mov

from primitives.

nuthinking avatar nuthinking commented on May 26, 2024

Thanks @vladmoroz for confirming this! It doesn't work for me though. This is my code, in a nutshell:

export const TeamSwitcher: React.FC<Props> = props => {
    const { teams, currentTeamId, onChange, onCreateNew } = props;
    const [portalContainer] = useState(() => document.getElementById("portal"));

    const currentTeam = defined(teams.find(t => t.id === currentTeamId));

    return (
        <DropdownMenu.Root>
            <DropdownMenu.Trigger tw="w-full p-2 flex items-center justify-center gap-3 rounded-xl hover:bg-n200A data-[state=open]:bg-n200A">
                <TeamListItem team={currentTeam} selected={false} />
            </DropdownMenu.Trigger>

            <DropdownMenu.Portal container={portalContainer}>
                <DropdownMenu.Content tw="p-1 min-w-[248px] shadow-md-dark bg-bg-front rounded-lg" align="start">
                    {teams.map(t => (
                        <DropdownMenu.Item
                            tw="p-2 hover:bg-n200A data-[highlighted]:bg-n200A rounded-xl"
                            key={t.id}
                            onClick={() => onChange(t.id)}>
                            <TeamListItem team={t} selected={t.id === currentTeamId} />
                        </DropdownMenu.Item>
                    ))}
                </DropdownMenu.Content>
            </DropdownMenu.Portal>
        </DropdownMenu.Root>
    );
};

Even without passing our portal doesn't work πŸ€·β€β™‚οΈ

from primitives.

nuthinking avatar nuthinking commented on May 26, 2024

The documentation example doesn't scroll either: https://codesandbox.io/s/jovial-carlos-wlzjnh

menu-scroll.mp4

from primitives.

vladmoroz avatar vladmoroz commented on May 26, 2024

@nuthinking your examples import the Dropdown Menu primitive which comes with no presentational styles like scroll. If that's what you wanted to use, you'll have to add an overflow style yourself or compose it with the Scroll Area.

If you wanted a themed Dropdown Menu component which comes with pre-defined styles and is pre-composed with the Scroll Area, you should get it from the @radix-ui/themes package

from primitives.

nuthinking avatar nuthinking commented on May 26, 2024

Gotcha! Adding overflow-y: auto to the content doesn't do anything. The element height is not modified. Any idea where I can find a working example? I would prefer not using the themed version. Thanks a lot! πŸ™

from primitives.

vladmoroz avatar vladmoroz commented on May 26, 2024

@nuthinking you need to add max-height to enable overflow. You can use --radix-dropdown-menu-content-available-height variable for that, here’s an example:
https://github.com/radix-ui/themes/blob/main/packages/radix-ui-themes/src/components/dropdown-menu.css

from primitives.

nuthinking avatar nuthinking commented on May 26, 2024

@vladmoroz thank you so much!

from primitives.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.