Skip to content

Commit

Permalink
fix height issue
Browse files Browse the repository at this point in the history
  • Loading branch information
oliviertassinari committed Jun 22, 2019
1 parent e5813c0 commit 7521d88
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 11 deletions.
6 changes: 5 additions & 1 deletion packages/material-ui-styles/src/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import { ponyfillGlobal } from '@material-ui/utils';

/* Warning if there are several instances of @material-ui/styles */
if (process.env.NODE_ENV !== 'production' && typeof window !== 'undefined') {
if (
process.env.NODE_ENV !== 'production' &&
process.env.NODE_ENV !== 'test' &&
typeof window !== 'undefined'
) {
ponyfillGlobal['__@material-ui/styles-init__'] =
ponyfillGlobal['__@material-ui/styles-init__'] || 0;

Expand Down
8 changes: 2 additions & 6 deletions packages/material-ui/src/MenuList/MenuList.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,7 @@ function textCriteriaMatches(nextFocus, textCriteria) {

function moveFocus(list, currentFocus, disableListWrap, traversalFunction, textCriteria) {
let wrappedOnce = false;
let nextFocus = traversalFunction(
list,
currentFocus,
currentFocus && currentFocus !== list ? disableListWrap : false,
);
let nextFocus = traversalFunction(list, currentFocus, currentFocus ? disableListWrap : false);

while (nextFocus) {
// Prevent infinite loop.
Expand Down Expand Up @@ -88,8 +84,8 @@ const MenuList = React.forwardRef(function MenuList(props, ref) {
actions,
autoFocus = false,
className,
disableListWrap = false,
onKeyDown,
disableListWrap = false,
...other
} = props;
const listRef = React.useRef(null);
Expand Down
12 changes: 12 additions & 0 deletions packages/material-ui/src/Select/Select.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,5 +105,17 @@ describe('<Select />', () => {
);
assert.strictEqual(wrapper.find(`.${classes.select}`).text(), 'Twenty');
});

it('should render a placeholder when the value is missing', () => {
const wrapper = mount(
<Select {...defaultProps} value={0}>
<MenuItem value={10}>Ten</MenuItem>
<MenuItem value={20}>Twenty</MenuItem>
<MenuItem value={30}>Thirty</MenuItem>
</Select>,
);
const selectDisplay = wrapper.find('[role="button"]');
assert.strictEqual(selectDisplay.find('span').exists(), true);
});
});
});
8 changes: 4 additions & 4 deletions packages/material-ui/src/Select/SelectInput.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ describe('<SelectInput />', () => {
<SelectInput {...defaultProps} SelectDisplayProps={{ 'data-test': 'SelectDisplay' }} />,
);

const selectDisplay = wrapper.find('[data-mui-test="SelectDisplay"]');
const selectDisplay = wrapper.find('[role="button"]');
assert.strictEqual(selectDisplay.props()['data-test'], 'SelectDisplay');
});
});
Expand Down Expand Up @@ -287,15 +287,15 @@ describe('<SelectInput />', () => {
describe('prop: autoWidth', () => {
it('should take the anchor width into account', () => {
const wrapper = mount(<SelectInput {...defaultProps} />);
const selectDisplay = wrapper.find('[data-mui-test="SelectDisplay"]').instance();
const selectDisplay = wrapper.find('[role="button"]').instance();
stub(selectDisplay, 'clientWidth').get(() => 14);
wrapper.find(`.${defaultProps.classes.select}`).simulate('click');
assert.strictEqual(wrapper.find(Menu).props().PaperProps.style.minWidth, 14);
});

it('should not take the anchor width into account', () => {
const wrapper = mount(<SelectInput {...defaultProps} autoWidth />);
const selectDisplay = wrapper.find('[data-mui-test="SelectDisplay"]').instance();
const selectDisplay = wrapper.find('[role="button"]').instance();
stub(selectDisplay, 'clientWidth').get(() => 14);
wrapper.find(`.${defaultProps.classes.select}`).simulate('click');
assert.strictEqual(wrapper.find(Menu).props().PaperProps.style.minWidth, null);
Expand All @@ -305,7 +305,7 @@ describe('<SelectInput />', () => {
describe('prop: multiple', () => {
it('should take precedence', () => {
const wrapper = shallow(<SelectInput {...defaultProps} disabled tabIndex={0} />);
assert.strictEqual(wrapper.find('[data-mui-test="SelectDisplay"]').props().tabIndex, 0);
assert.strictEqual(wrapper.find('[role="button"]').props().tabIndex, 0);
});

it('should serialize multiple select value', () => {
Expand Down

0 comments on commit 7521d88

Please # to comment.