Git Product home page Git Product logo

Comments (7)

sindresorhus avatar sindresorhus commented on July 4, 2024 1

Makes sense, but should be based on id, not the label. I don't think we need an option for it. Should the replaced item take the original position or be added to the start/end depending on whether prepend/append was used? I'm leaning towards the latter.

We currently have a shouldShowMenu option, so it could also maybe be useful with one for menu items called shouldShowMenuItem? In case you want to dynamically decide which of the items to show.

from electron-context-menu.

sindresorhus avatar sindresorhus commented on July 4, 2024 1

but one would want to localize this library too

It would be weird to have to translate the menu item here when you don't use it and instead override it with your. These are many reasons why as stable ID is better.

from electron-context-menu.

fabiospampinato avatar fabiospampinato commented on July 4, 2024

Makes sense, but should be based on id, not the label.

Maybe if no id is explicitly provided but the label is the same as a default menu item that default menu item should still be omitted? I just can't imagine a scenario where one would want 2 "Copy" menu items like shown in the screenshot.

Should the replaced item take the original position or be added to the start/end depending on whether prepend/append was used?

I'd say the latter too.

We currently have a shouldShowMenu option, so it could also maybe be useful with one for menu items called shouldShowMenuItem? In case you want to dynamically decide which of the items to show.

Maybe, I'm currently updating the menus inside shouldShowMenu before showing them (ref).

If there was a shouldShowMenuItem item option I think that could be useful in some scenarios, but I would personally not use it as whether or not some menu items should be shown may depend on some computation that I'd rather perform once for all items rather than for each time and I'd rather perform it next to the logic for updating the menu itself rather than in a different place.

Maybe an updateMenu option, maybe called with the entire menu template before showing it, could be useful too.

I'd be happy to submit a PR implementing these features πŸ‘

from electron-context-menu.

sindresorhus avatar sindresorhus commented on July 4, 2024

Maybe if no id is explicitly provided but the label is the same as a default menu item that default menu item should still be omitted? I just can't imagine a scenario where one would want 2 "Copy" menu items like shown in the screenshot.

The reason I want to base it on id is that menu items could be localized and that could create ambiguity. It's just easier to reason about if it's only based on the id.

Maybe an updateMenu option, maybe called with the entire menu template before showing it, could be useful too.

πŸ‘ That actually sounds more useful and flexible than my shouldShowMenuItem idea.

from electron-context-menu.

fabiospampinato avatar fabiospampinato commented on July 4, 2024

The reason I want to base it on id is that menu items could be localized and that could create ambiguity. It's just easier to reason about if it's only based on the id.

I see your point, but some apps don't deal with i18n at all, and those who do I guess would translate "Copy" from this library and the custom "Copy" item with the same string πŸ€”

I'll try to get the PR done by the end of the week πŸ‘

from electron-context-menu.

sindresorhus avatar sindresorhus commented on July 4, 2024

I see your point, but some apps don't deal with i18n at all, and those who do I guess would translate "Copy" from this library and the custom "Copy" item with the same string πŸ€”

I was referring to depending on overriding the "Copy" item here, then localizing and suddenly the override stops working as the labels no longer match.

from electron-context-menu.

fabiospampinato avatar fabiospampinato commented on July 4, 2024

Yeah yeah, but one would want to localize this library too and assuming both instances of "Copy" get localized to the same string (but languages are complicated, maybe this assumption can't be made) the override would still work.

from electron-context-menu.

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.