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

chore(dialog): Remove ripple layout & layoutFooterRipples adapter API #2570

Merged
merged 5 commits into from
Apr 16, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions packages/mdc-dialog/foundation.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ export default class MDCDialogFoundation extends MDCFoundation {
trapFocusOnSurface: () => {},
untrapFocusOnSurface: () => {},
isDialog: (/* el: Element */) => /* boolean */ false,
layoutFooterRipples: () => {},
};
}

Expand Down Expand Up @@ -138,7 +137,6 @@ export default class MDCDialogFoundation extends MDCFoundation {
this.adapter_.removeClass(MDCDialogFoundation.cssClasses.ANIMATING);
if (this.isOpen_) {
this.adapter_.trapFocusOnSurface();
this.adapter_.layoutFooterRipples();
} else {
this.enableScroll_();
};
Expand Down
1 change: 0 additions & 1 deletion packages/mdc-dialog/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ export class MDCDialog extends MDCComponent {
trapFocusOnSurface: () => this.focusTrap_.activate(),
untrapFocusOnSurface: () => this.focusTrap_.deactivate(),
isDialog: (el) => el === this.dialogSurface_,
layoutFooterRipples: () => this.footerBtnRipples_.forEach((ripple) => ripple.layout()),
});
}
}
11 changes: 0 additions & 11 deletions test/unit/mdc-dialog/foundation.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ test('default adapter returns a complete adapter implementation', () => {
'registerDocumentKeydownHandler', 'deregisterDocumentKeydownHandler',
'registerTransitionEndHandler', 'deregisterTransitionEndHandler',
'notifyAccept', 'notifyCancel', 'trapFocusOnSurface', 'untrapFocusOnSurface', 'isDialog',
'layoutFooterRipples',
]);
});

Expand Down Expand Up @@ -158,16 +157,6 @@ test('#close deactivates focus trapping on the dialog surface', () => {
td.verify(mockAdapter.untrapFocusOnSurface());
});

test('#open calls adapter method to re-layout footer ripples', () => {
const {foundation, mockAdapter} = setupTest();

td.when(mockAdapter.registerTransitionEndHandler(td.callback)).thenCallback({target: {}});
td.when(mockAdapter.isDialog(td.matchers.isA(Object))).thenReturn(true);
foundation.open();

td.verify(mockAdapter.layoutFooterRipples());
});

test('#accept closes the dialog', () => {
const {foundation} = setupTest();

Expand Down
26 changes: 0 additions & 26 deletions test/unit/mdc-dialog/mdc-dialog.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,13 @@
* limitations under the License.
*/

// This suite requires hooks to stub (and clean up) MDCRipple#layout.
/* eslint mocha/no-hooks: "off" */

import {assert} from 'chai';
import bel from 'bel';
import domEvents from 'dom-events';
import td from 'testdouble';
import {createMockRaf} from '../helpers/raf';
import {strings} from '../../../packages/mdc-dialog/constants';
import {MDCDialog, util} from '../../../packages/mdc-dialog';
import {MDCRipple} from '../../../packages/mdc-ripple';
import {supportsCssVariables} from '../../../packages/mdc-ripple/util';

function getFixture() {
Expand Down Expand Up @@ -73,22 +69,6 @@ function hasClassMatcher(className) {

suite('MDCDialog');

const originalLayout = MDCRipple.prototype.layout;
const stubbedLayout = td.func('MDCRipple#layout');

before(() => {
MDCRipple.prototype.layout = stubbedLayout;
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove import of MDCRipple
24:9 error 'MDCRipple' is defined but never used. Allowed unused vars must match /^(?:(?:MDC(?:(?:[A-Z][a-z0-9]+)+)Adapter)|(?:(?:(?:[A-Z][a-z0-9]+)+)Type))$/ no-unused-vars

});

afterEach(() => {
// Ensure that stubbedLayout's call count resets between tests
td.reset();
});

after(() => {
MDCRipple.prototype.layout = originalLayout;
});

test('attachTo returns a component instance', () => {
assert.isOk(MDCDialog.attachTo(getFixture().querySelector('.mdc-dialog')) instanceof MDCDialog);
});
Expand Down Expand Up @@ -332,9 +312,3 @@ test('adapter#isDialog returns false for a non-dialog surface element', () => {
const {root, component} = setupTest();
assert.isNotOk(component.getDefaultFoundation().adapter_.isDialog(root));
});

test('adapter#layoutFooterRipples calls layout on each footer button\'s ripple instance', () => {
const {component} = setupTest();
component.getDefaultFoundation().adapter_.layoutFooterRipples();
td.verify(stubbedLayout(), {times: 2});
});