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

Menu Separator #7790

Open
ogoffart opened this issue Mar 4, 2025 · 4 comments
Open

Menu Separator #7790

ogoffart opened this issue Mar 4, 2025 · 4 comments
Labels
a:language-slint Compiler for the .slint language (mO,bF) enhancement New feature or request

Comments

@ogoffart
Copy link
Member

ogoffart commented Mar 4, 2025

We should add a MenuSeparator {} (or just Separator{} ?) element in Menu that acts as a menu separator

Menu {
    MenuItem { ... }
    Separator{}
    MenuItem { ... }
    MenuItem { ... }
    Separator{}
    MenuItem { ... }
}

Separator at the beginning or at the end should be ignored. Multiple separator in a row should result in only one separator.

@ogoffart ogoffart added a:language-slint Compiler for the .slint language (mO,bF) enhancement New feature or request labels Mar 4, 2025
@tronical
Copy link
Member

tronical commented Mar 4, 2025

An idea that @NigelBreslaw brought up was instead of a Separator {}, use grouping:

Menu {
    MenuItemGroup {
        MenuItem { ... }
        MenuItem { ... }
    }
    MenuItem { ... }
}

Separators are inserted automatically at the edges of groups, unless they are at the beginning or the end of the menu. Between two adjacent groups, only one separator gets inserted.

This approach also has the advantage that it plays well with dynamic menus and avoids having to have logic that eliminates trailing or leading separators.

@ogoffart
Copy link
Member Author

ogoffart commented Mar 4, 2025

This approach also has the advantage that it plays well with dynamic menus

Could you elaborate?

avoids having to have logic that eliminates trailing or leading separators.

That's not very elaborate logic. The logic to understand MenuItemGroup and place separator accordingly seems more elaborate.

@NigelBreslaw
Copy link
Member

I looked into this a bit more and although React Native Reusables(RnR) abstracts the separator away, the libraries that inspired it like Radix and Shadcn have a separator. Which seems to make sense as the 2 later libraries should allow you to make anything, while RnR is bit more restrictive to do more things automatically for you. So probably the lower level menu should have a separator? RnR does make sense though because MenuGroups are not the only group it offers. You don't have to explicitly say 'this is a submenu'. You add a MenuSub group. Same for radio menus which are just menu items inside a MenubarRadioGroup.

@NigelBreslaw
Copy link
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a:language-slint Compiler for the .slint language (mO,bF) enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants