Skip to content
This repository has been archived by the owner on Jun 28, 2021. It is now read-only.

Commit

Permalink
fix(Tabs): Fix js error when clicking on a tab (#376)
Browse files Browse the repository at this point in the history
Fixes #347
  • Loading branch information
tleunen authored and Tommy Leunen committed Aug 20, 2016
1 parent 9ab92f9 commit ca9309e
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 8 deletions.
38 changes: 38 additions & 0 deletions extra/layout-patch.diff
@@ -1,3 +1,14 @@
From d80b2b024533a0807cc9e51a56dca54ebca25cef Mon Sep 17 00:00:00 2001
From: Tommy Leunen <tommy.leunen+github@gmail.com>
Date: Sat, 20 Aug 2016 12:35:46 -0400
Subject: [PATCH] react mdl 1.2.0

---
src/layout/_layout.scss | 34 +++++++++++++++++-----------------
src/layout/layout.js | 26 ++++++++++----------------
src/mdlComponentHandler.js | 3 ++-
3 files changed, 29 insertions(+), 34 deletions(-)

diff --git a/src/layout/_layout.scss b/src/layout/_layout.scss
index 13a5156..d4e21b9 100644
--- a/src/layout/_layout.scss
Expand Down Expand Up @@ -219,3 +230,30 @@ index e4e6523..5d3c1a8 100644
} else {
/**
* Dummy function to avoid JS errors.
2.9.3

From d54f216cabacee65cdd687a78b5abbe0739f7253 Mon Sep 17 00:00:00 2001
From: Tommy Leunen <tommy.leunen+github@gmail.com>
Date: Sat, 20 Aug 2016 12:45:29 -0400
Subject: [PATCH] Fix fake tab click

---
src/layout/layout.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/layout/layout.js b/src/layout/layout.js
index c4574ef..369f585 100644
--- a/src/layout/layout.js
+++ b/src/layout/layout.js
@@ -525,7 +525,7 @@
*/
function selectTab() {
var href = tab.href.split('#')[1];
- var panel = layout.content_.querySelector('#' + href);
+ var panel = layout.header_.querySelector('#' + href);
layout.resetTabState_(tabs);
layout.resetPanelState_(panels);
tab.classList.add(layout.CssClasses_.IS_ACTIVE);
--
2.9.3

2 changes: 1 addition & 1 deletion extra/material.js
Expand Up @@ -3557,7 +3557,7 @@ function MaterialLayoutTab(tab, tabs, panels, layout) {
*/
function selectTab() {
var href = tab.href.split('#')[1];
var panel = layout.content_.querySelector('#' + href);
var panel = layout.header_.querySelector('#' + href);
layout.resetTabState_(tabs);
layout.resetPanelState_(panels);
tab.classList.add(layout.CssClasses_.IS_ACTIVE);
Expand Down
2 changes: 1 addition & 1 deletion extra/material.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion extra/material.min.js.map

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions src/Tabs/TabBar.js
Expand Up @@ -40,10 +40,11 @@ class TabBar extends React.Component {
cssPrefix,
tabId,
active: tabId === activeTab,
onTabClick: this.handleClickTab
onTabClick: this.handleClickTab,
href: '#react-mdl-tabs-hack',
})
)}

<span id="react-mdl-tabs-hack" />
</div>
);
}
Expand Down
10 changes: 7 additions & 3 deletions src/Tabs/Tabs.js
Expand Up @@ -2,6 +2,7 @@ import React, { PropTypes } from 'react';
import classNames from 'classnames';
import Tab from './Tab';
import TabBar from './TabBar';
import mdlUpgrade from '../utils/mdlUpgrade';

const TabPropType = (props, propName, componentName) => {
const prop = props[propName];
Expand All @@ -17,13 +18,16 @@ const propTypes = {
className: PropTypes.string,
onChange: PropTypes.func,
tabBarProps: PropTypes.object,
ripple: PropTypes.bool,
};

const Tabs = props => {
const { activeTab, className, onChange,
children, tabBarProps, ...otherProps } = props;
children, tabBarProps, ripple, ...otherProps } = props;

const classes = classNames('mdl-tabs is-upgraded', className);
const classes = classNames('mdl-tabs mdl-js-tabs is-upgraded', {
'mdl-js-ripple-effect': ripple
}, className);

return (
<div className={classes} {...otherProps}>
Expand All @@ -36,4 +40,4 @@ const Tabs = props => {

Tabs.propTypes = propTypes;

export default Tabs;
export default mdlUpgrade(Tabs);

0 comments on commit ca9309e

Please sign in to comment.