-
-
Notifications
You must be signed in to change notification settings - Fork 448
Custom tabpanel selected class #149
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
Custom tabpanel selected class #149
Conversation
@@ -24,28 +25,37 @@ module.exports = React.createClass({ | |||
getDefaultProps() { | |||
return { | |||
selected: false, | |||
selectedClassName: null, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
selectedClassName: 'ReactTabs__TabPanel--selected'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is null
in order to satisfy inline styles condition on line 42.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although I do think it is too much implicit logic going on.
const { | ||
id, tabId, selected, | ||
className, selectedClassName, style, children, | ||
...attrs, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why did you change this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The line got 105 characters long, which didn't pass the linting.
...attrs, | ||
} = this.props; | ||
|
||
// Only hide using inline styles if `selectedClassName` isn't provided |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The idea is that if you specify your own custom classes, you want control over hiding/showing. With inline styles you would have to override using !important
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could also just follow the design of the Tab
component which only uses overridable classes.
The case I ran into was that I needed hidden TabPanel
s to still take up their natural height, i.e. setting visibility: hidden;
instead on the inline display: none;
.
This PR does the following:
<TabPanel>
s using a newselectedClassName
prop;display: none;
to the<TabPanel>
if a customselectedClassName
prop has not been provided; andMy use case is that I need to keep the contents of hidden tabs and give them a bunch of styles in order to maintain the parent's dimensions.