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

Allow empty menus to activate in menu bar #729

Open
sdirix opened this issue Nov 28, 2024 · 1 comment
Open

Allow empty menus to activate in menu bar #729

sdirix opened this issue Nov 28, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@sdirix
Copy link

sdirix commented Nov 28, 2024

Hi! I'm working on migrating to Lumino in Theia. We’ve previously relied on PhosphorJS, and decided to transition to Lumino.

Problem

We implemented a DynamicMenuWidget whose core functionality involves dynamically calculating its menu items just before being shown. This worked in PhosphorJS

However, we’ve encountered an issue with Lumino due to a change introduced in #607. Specifically, this check in the MenuBar prevents our menus from activating:

    // An empty menu cannot be active
    if (value > -1 && this._menus[value].items.length === 0) {
      value = -1;
    }

As a result, Theia’s dynamic menus are never activated and therefore never displayed.

Workarounds

We’ve explored a few workarounds:

  • Patching Lumino locally via patch-package to remove the check, but this requires maintenance with every new Lumino release.
  • Subclassing MenuBar and overriding the activeIndex setter to bypass the check, but this requires duplicating the setter code and working around type checks on private fields.

Both approaches feel brittle and suboptimal for long-term maintenance.

Proposed Solution?

Would you be open to changes that make the MenuBar more flexible for downstream adopters like us? If so, we’d appreciate your input on the best way forward. Some potential approaches:

  • Removing the check entirely if it’s not critical for some other use cases
  • Making private fields protected in MenuBar to allow subclassing without type workarounds.
  • Moving the check into a separate method that subclasses can override.

Alternatively, if you have suggestions for a better way to implement dynamic menus in Theia that align more closely with Lumino's current design, I’d be very interested to hear your thoughts.

Thanks for all your work on Lumino—it’s a fantastic library, and we look forward to using it in Theia!

@sdirix sdirix added the enhancement New feature or request label Nov 28, 2024
@krassowski
Copy link
Member

CC @gabalafou as author of #607.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants