Skip to content

Auto hide context menu separator, when first or last child #8446

@stefanuebe

Description

@stefanuebe

Describe your motivation

The context menu method addSeparator() adds an Hr to show a visible separator between two menu items.

Unfortunately, it does not check, if the separator might be the first or last child. In context menus, that show some items only under certain conditions, this may lead to unwanted "artifacts", if not handled properly.

The dev could of course check, if a separator has to be added, but this may lead to unnecessary boilerplate code, if there are several conditions, where items could be shown or not.

Describe the solution you'd like

Since a context menu separator is not a critical element, but more a visual help for the user, it should not be a problem to hide it automatically, when it makes no sense to show a separator.

To achieve this, the context menu should add respective styles:

vaadin-context-menu-list-box {
    hr:first-child {
        display: none;
    }
    hr:last-child {
        display: none;
    }
}

Describe alternatives you've considered

Implementing it on my own.

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions