Skip to content

Commit

Permalink
Merge pull request react-bootstrap#1419 from taion/disallow-justified…
Browse files Browse the repository at this point in the history
…-navbar

[fixed] Explicitly disallow justified Navbar Navs
  • Loading branch information
jquense committed Oct 18, 2015
2 parents 80b963e + 6bad1e8 commit 36a332d
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
20 changes: 16 additions & 4 deletions src/Nav.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import React, { cloneElement } from 'react';
import BootstrapMixin from './BootstrapMixin';
import Collapse from './Collapse';
import classNames from 'classnames';
import React, { cloneElement } from 'react';
import all from 'react-prop-types/lib/all';

import ValidComponentChildren from './utils/ValidComponentChildren';
import createChainedFunction from './utils/createChainedFunction';

import BootstrapMixin from './BootstrapMixin';
import Collapse from './Collapse';

const Nav = React.createClass({
mixins: [BootstrapMixin],

Expand All @@ -14,7 +16,17 @@ const Nav = React.createClass({
activeKey: React.PropTypes.any,
bsStyle: React.PropTypes.oneOf(['tabs', 'pills']),
stacked: React.PropTypes.bool,
justified: React.PropTypes.bool,
/**
* Make `NavItem`s equal widths on small or larger displays and stacked
* otherwise. Not supported for `Nav`s in `Navbar`s.
*/
justified: all(
React.PropTypes.bool,
({justified, navbar}) => (
justified && navbar ?
Error('justified navbar `Nav`s are not supported') : null
)
),
onSelect: React.PropTypes.func,
collapsible: React.PropTypes.bool,
/**
Expand Down
9 changes: 9 additions & 0 deletions test/NavSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import Button from '../src/Button';
import Nav from '../src/Nav';
import NavItem from '../src/NavItem';

import {shouldWarn} from './helpers';

describe('Nav', () => {
it('Should set the correct item active', () => {
let instance = ReactTestUtils.renderIntoDocument(
Expand Down Expand Up @@ -178,6 +180,13 @@ describe('Nav', () => {
assert.equal(navNode.id, 'nav-id');
});

it('Should warn when attempting to use a justified navbar nav', () => {
ReactTestUtils.renderIntoDocument(
<Nav navbar justified />
);

shouldWarn('justified navbar `Nav`s are not supported');
});

describe('Web Accessibility', () => {

Expand Down

0 comments on commit 36a332d

Please sign in to comment.