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(menu): Add quickOpen option. #2127

Merged
merged 9 commits into from
Feb 1, 2018

Conversation

williamernest
Copy link
Contributor

Fixes: #1702
Disables open and closing animations for the mdc-menu element.

@codecov-io
Copy link

codecov-io commented Jan 30, 2018

Codecov Report

Merging #2127 into master will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2127      +/-   ##
==========================================
+ Coverage   99.13%   99.14%   +<.01%     
==========================================
  Files          90       90              
  Lines        3831     3840       +9     
  Branches      491      495       +4     
==========================================
+ Hits         3798     3807       +9     
  Misses         33       33
Impacted Files Coverage Δ
packages/mdc-menu/index.js 93.97% <100%> (+0.14%) ⬆️
packages/mdc-menu/foundation.js 99.35% <100%> (+0.01%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 17c6c51...64e6319. Read the comment docs.

@@ -208,6 +210,11 @@ class MDCMenuFoundation extends MDCFoundation {
this.setSelectedIndex(-1);
}

/** @param {boolean} quickOpen */
quickOpen(quickOpen) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be called setQuickOpen? The current name in the context of a method makes it sound like it's actually going to open the menu.

this.adapter_.addClass(MDCMenuFoundation.cssClasses.ANIMATING_OPEN);

if (!this.quickOpen_) {
this.adapter_.addClass(MDCMenuFoundation.cssClasses.ANIMATING_OPEN);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably also conditionalize the setTimeout code below (and same for within close), although it's effectively a no-op in this case right now.

td.verify(mockAdapter.addClass(cssClasses.ANIMATING_OPEN), {times: 1});
});

testFoundation('#open does not add the animation class to start an animation when quickOpen is false',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing a complementary test for #close? (Also test both addClass and removeClass after addressing my comment above.)

@@ -150,6 +153,7 @@ Property | Value Type | Description
`open` | Boolean | Proxies to the foundation's `isOpen`/(`open`, `close`) methods.
`items` | Array<Element> | Proxies to the foundation's container to query for all `.mdc-list-item[role]` elements.
`itemsContainer` | Element | Queries the foundation's root element for the `mdc-menu__items` container element.
`quickOpen` | Boolean | Proxies to the foundation's `quickOpen()` method.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Description needs updating to setQuickOpen() now

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It also occurs to me that setQuickOpen needs to be documented under the Foundation API... and make sure to mention that it affects both open and close animations. (Which makes me think maybe this isn't the best name, but not sure what is... maybe flip it to enableAnimations, but maybe that's too vague?)

@@ -201,6 +205,7 @@ Method Signature | Description
`open({focusIndex: ?number}) => void` | Opens the menu. Optionally accepts an object with a `focusIndex` parameter to indicate which list item should receive focus when the menu is opened.
`close(evt: ?Event)` | Closes the menu. Optionally accepts the event to check if the target is disabled before closing the menu.
`isOpen() => boolean` | Returns a boolean indicating whether the menu is open.
`setQuickOpen(quickOpen: boolean) => void` | Sets the menu to open and close without animation when the `open/close` methods are called.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit #1: "Whether the menu should open and close ..."
Nit #2: open/close (separate backticks around each word, leave the slash outside them)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed it to "Sets whether the menu should open and close..." based on every other "set" method description in this readme starting with "Sets".

@williamernest williamernest force-pushed the feat/menu/open-menu-no-animation branch from 4e4a51f to 3b43351 Compare February 1, 2018 22:53
@williamernest williamernest force-pushed the feat/menu/open-menu-no-animation branch from 3b43351 to f1d7d4d Compare February 1, 2018 22:55
@williamernest williamernest force-pushed the feat/menu/open-menu-no-animation branch from d286d22 to 64e6319 Compare February 1, 2018 23:17
@williamernest williamernest merged commit e571a53 into master Feb 1, 2018
@williamernest williamernest deleted the feat/menu/open-menu-no-animation branch February 1, 2018 23:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants