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

feat: add window removeMenu() method #16570

Merged
merged 3 commits into from Jan 31, 2019
Merged

feat: add window removeMenu() method #16570

merged 3 commits into from Jan 31, 2019

Conversation

codebytere
Copy link
Member

@codebytere codebytere commented Jan 28, 2019

Description of Change

This PR adds win.removeMenu() as a replacement for win.setMenu(null), which is less intuitive and a bit of an antipattern for modern JS. We can most likely backport the additional method into 5-0-x and only remove the original in master.

cc @MarshallOfSound @ckerr

Checklist

Release Notes

Notes: Added win.removeMenu() to remove application menus instead of using win.setMenu(null).

@codebytere codebytere requested review from a team January 28, 2019 17:46
@miniak
Copy link
Contributor

miniak commented Jan 28, 2019

@codebytere I don't like this change much. In many frameworks, you would have a property menu or something similar, where assigning null to that would remove the menu, icon, etc.

@codebytere
Copy link
Member Author

@miniak JS frameworks, & modern ones? Using null to mean no argument as a removal mechanism is an anti-pattern at this point, as new features like default parameters only work with undefined

I think explicit functions for removal should be preferred over some of our current patterns, with the end goal being getters and setters

@miniak
Copy link
Contributor

miniak commented Jan 28, 2019

@codebytere how would the API look like with getters/setters? you won't be able to assign null / undefined to the property and we'll still have the remove method? the getter can still return a falsy value. Which means that win.menu = win.menu can blow up :)

@MarshallOfSound
Copy link
Member

@miniak This is an API improvement we can do in a non-breaking way to better support modern styles of JS. Calling setThing(null) to remove it is not as idiomatic as removeThing().

This isn't a final "this is the best API we can build", this is a "this is the best API we can build without changing our entire API". Discussions around future API design like setters and getters instead of methods are a much wider discussion and something that I believe is on the list of proposed topics for summit.

For now, this PR is a noticeable API improvement and reduces confusion around usage.

@codebytere
Copy link
Member Author

2019-01-31T02:57:43.7306876Z atom/browser/atom_download_manager_delegate.cc:130:  You don't need a ; after a }

🤔 i don't even change that file in this PR

@release-clerk
Copy link

release-clerk bot commented Jan 31, 2019

Release Notes Persisted

Added win.removeMenu() to remove application menus instead of using win.setMenu(null).

@trop
Copy link
Contributor

trop bot commented Jan 31, 2019

I have automatically backported this PR to "5-0-x", please check out #16657

@sofianguy sofianguy added this to 5.0.0-beta.3 in 5.0.x Feb 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver/minor backwards-compatible functionality
Projects
No open projects
5.0.x
Fixed in 5.0.0-beta.3
Development

Successfully merging this pull request may close these issues.

None yet

3 participants