google / google/material-design-lite

move positioning code from MaterialMenu.prototype.handleForClick_ into public api

Open
#1,701 4 comments 0 reactions 0 assignees View on GitHub
Menu
Dominant language
HTML
Stars
32.2k
Forks
4.9k
PR merge metrics
No merged PRs in 30d

Description

MaterialMenu exposes a show() command in its public API, but it would be a lot easier to use if the positioning code that is currently in the handleForClick_ private handler of the click event was available publicly, as show() does no positioning, so you are left to essentially duplicate the positioning from inside handleForClick_ in your own code.

It might be simplest to put the positioning into show() as the positioning code does check for the case where the user is handling the position themselves due to not assigning a position class, but the user might want to supply a position class , so it is perhaps best to add a separate setPosition() call.

I wasn't sure, but it also looks like handleForClick_ might be needlessly doing positioning when the menu is only going to be hidden (i.e. the positioning code is all done before the toggle call is made, so is down irrespectively of whether you are toggling the menu on or off).

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.