Skip to content
This repository has been archived by the owner on Jan 13, 2025. It is now read-only.

Commit

Permalink
feat(tab): Remove activation event emitting (#3242)
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickrodee authored Jul 26, 2018
1 parent 052bc9e commit 44c9261
Show file tree
Hide file tree
Showing 7 changed files with 1 addition and 27 deletions.
2 changes: 0 additions & 2 deletions packages/mdc-tab/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ Method Signature | Description
Event Name | Event Data Structure | Description
--- | --- | ---
`MDCTab:interacted` | `{"detail": {"tab": MDCTab}}` | Emitted when the Tab is interacted with, regardless of its active state. Used by parent components to know which Tab to activate.
`MDCTab:activated` | `{"detail": {"tab": MDCTab}}` | Emitted when the Tab is activated. Listen for this to update content when a Tab becomes active.

## Usage within Web Frameworks

Expand All @@ -154,7 +153,6 @@ Method Signature | Description
`getContentOffsetLeft() => number` | Returns the `offsetLeft` value of the content element.
`getContentOffsetWidth() => number` | Returns the `offsetWidth` value of the content element.
`notifyInteracted() => void` | Emits the `MDCTab:interacted` event.
`notifyActivated() => void` | Emits the `MDCTab:activated` event.
`focus() => void` | Applies focus to the root element.

### `MDCTabFoundation`
Expand Down
5 changes: 0 additions & 5 deletions packages/mdc-tab/adapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,6 @@ class MDCTabAdapter {
*/
notifyInteracted() {}

/**
* Emits the MDCTab:activated event for use by parent components
*/
notifyActivated() {}

/**
* Returns the offsetLeft value of the root element.
* @return {number}
Expand Down
1 change: 0 additions & 1 deletion packages/mdc-tab/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ const strings = {
TAB_INDICATOR_SELECTOR: '.mdc-tab-indicator',
TABINDEX: 'tabIndex',
INTERACTED_EVENT: 'MDCTab:interacted',
ACTIVATED_EVENT: 'MDCTab:activated',
};

export {
Expand Down
2 changes: 0 additions & 2 deletions packages/mdc-tab/foundation.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ class MDCTabFoundation extends MDCFoundation {
deactivateIndicator: () => {},
computeIndicatorClientRect: () => {},
notifyInteracted: () => {},
notifyActivated: () => {},
getOffsetLeft: () => {},
getOffsetWidth: () => {},
getContentOffsetLeft: () => {},
Expand Down Expand Up @@ -129,7 +128,6 @@ class MDCTabFoundation extends MDCFoundation {
this.adapter_.setAttr(strings.TABINDEX, '0');
this.adapter_.activateIndicator(previousIndicatorClientRect);
this.adapter_.focus();
this.adapter_.notifyActivated();
}

/**
Expand Down
1 change: 0 additions & 1 deletion packages/mdc-tab/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ class MDCTab extends MDCComponent {
deactivateIndicator: () => this.tabIndicator_.deactivate(),
computeIndicatorClientRect: () => this.tabIndicator_.computeContentClientRect(),
notifyInteracted: () => this.emit(MDCTabFoundation.strings.INTERACTED_EVENT, {tab: this}, true /* bubble */),
notifyActivated: () => this.emit(MDCTabFoundation.strings.ACTIVATED_EVENT, {tab: this}, true /* bubble */),
getOffsetLeft: () => this.root_.offsetLeft,
getOffsetWidth: () => this.root_.offsetWidth,
getContentOffsetLeft: () => this.content_.offsetLeft,
Expand Down
8 changes: 1 addition & 7 deletions test/unit/mdc-tab/foundation.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ test('defaultAdapter returns a complete adapter implementation', () => {
'setAttr',
'activateIndicator', 'deactivateIndicator', 'computeIndicatorClientRect',
'getOffsetLeft', 'getOffsetWidth', 'getContentOffsetLeft', 'getContentOffsetWidth',
'notifyInteracted', 'notifyActivated',
'notifyInteracted',
'focus',
]);
});
Expand Down Expand Up @@ -95,12 +95,6 @@ test('#activate focuses the root node', () => {
td.verify(mockAdapter.focus());
});

test(`#activate emits the ${MDCTabFoundation.strings.ACTIVATED_EVENT} event`, () => {
const {foundation, mockAdapter} = setupTest();
foundation.activate();
td.verify(mockAdapter.notifyActivated());
});

test('#computeIndicatorClientRect calls computeIndicatorClientRect on the adapter', () => {
const {foundation, mockAdapter} = setupTest();
foundation.computeIndicatorClientRect();
Expand Down
9 changes: 0 additions & 9 deletions test/unit/mdc-tab/mdc-tab.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,15 +159,6 @@ test(`#adapter.notifyInteracted() emits the ${MDCTabFoundation.strings.INTERACTE
td.verify(handler(td.matchers.anything()));
});

test(`#adapter.notifyActivated() emits the ${MDCTabFoundation.strings.ACTIVATED_EVENT} event`, () => {
const {component} = setupTest();
const handler = td.func('interaction handler');

component.listen(MDCTabFoundation.strings.ACTIVATED_EVENT, handler);
component.getDefaultFoundation().adapter_.notifyActivated();
td.verify(handler(td.matchers.anything()));
});

function setupMockFoundationTest(root = getFixture()) {
const MockFoundationConstructor = td.constructor(MDCTabFoundation);
const mockFoundation = new MockFoundationConstructor();
Expand Down

0 comments on commit 44c9261

Please sign in to comment.