Skip to content
Snippets Groups Projects
Commit 07034164 authored by Jessie Keck's avatar Jessie Keck Committed by Chris Beer
Browse files

Align the WindowTopMenu and add the selected state styling to the...

Align the WindowTopMenu and add the selected state styling to the WindowTopMenuButton when the menu is open.
parent 458bbe18
No related branches found
No related tags found
No related merge requests found
...@@ -10,7 +10,7 @@ function createWrapper(props) { ...@@ -10,7 +10,7 @@ function createWrapper(props) {
return shallow( return shallow(
<WindowTopMenuButton <WindowTopMenuButton
windowId="xyz" windowId="xyz"
classes={{}} classes={{ ctrlBtnSelected: 'ctrlBtnSelected' }}
t={str => str} t={str => str}
{...props} {...props}
/>, />,
...@@ -51,4 +51,13 @@ describe('WindowTopMenuButton', () => { ...@@ -51,4 +51,13 @@ describe('WindowTopMenuButton', () => {
wrapper.instance().handleMenuClose(); wrapper.instance().handleMenuClose();
expect(wrapper.find(WindowTopMenu).first().props().anchorEl).toBe(null); expect(wrapper.find(WindowTopMenu).first().props().anchorEl).toBe(null);
}); });
it('the button has a class indicating that it is "selected" once it is clicked', () => {
const wrapper = createWrapper();
expect(wrapper.find('.ctrlBtnSelected').length).toBe(0);
wrapper.find('WithStyles(IconButton)').simulate('click', { currentTarget: 'anElement' });
expect(wrapper.find('.ctrlBtnSelected').length).toBe(1);
wrapper.find('WithStyles(IconButton)').simulate('click', {});
expect(wrapper.find('.ctrlBtnSelected').length).toBe(0);
});
}); });
...@@ -26,6 +26,15 @@ export class WindowTopMenu extends Component { ...@@ -26,6 +26,15 @@ export class WindowTopMenu extends Component {
id={`window-menu_${windowId}`} id={`window-menu_${windowId}`}
container={document.querySelector(`#${containerId} .${ns('viewer')}`)} container={document.querySelector(`#${containerId} .${ns('viewer')}`)}
anchorEl={anchorEl} anchorEl={anchorEl}
anchorOrigin={{
vertical: 'bottom',
horizontal: 'right',
}}
transformOrigin={{
vertical: 'top',
horizontal: 'right',
}}
getContentAnchorEl={null}
open={Boolean(anchorEl)} open={Boolean(anchorEl)}
onClose={handleClose} onClose={handleClose}
> >
......
import React, { Component } from 'react'; import React, { Component } from 'react';
import IconButton from '@material-ui/core/IconButton'; import IconButton from '@material-ui/core/IconButton';
import MoreVertIcon from '@material-ui/icons/MoreVertSharp'; import MoreVertIcon from '@material-ui/icons/MoreVertSharp';
import classNames from 'classnames';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import WindowTopMenu from '../containers/WindowTopMenu'; import WindowTopMenu from '../containers/WindowTopMenu';
...@@ -50,7 +51,7 @@ export class WindowTopMenuButton extends Component { ...@@ -50,7 +51,7 @@ export class WindowTopMenuButton extends Component {
<IconButton <IconButton
color="inherit" color="inherit"
aria-label={t('windowMenu')} aria-label={t('windowMenu')}
className={classes.ctrlBtn} className={classNames(classes.ctrlBtn, (anchorEl ? classes.ctrlBtnSelected : null))}
aria-haspopup="true" aria-haspopup="true"
onClick={this.handleMenuClick} onClick={this.handleMenuClick}
aria-owns={anchorEl ? `window-menu_${windowId}` : undefined} aria-owns={anchorEl ? `window-menu_${windowId}` : undefined}
......
...@@ -13,6 +13,9 @@ const styles = theme => ({ ...@@ -13,6 +13,9 @@ const styles = theme => ({
ctrlBtn: { ctrlBtn: {
margin: theme.spacing.unit, margin: theme.spacing.unit,
}, },
ctrlBtnSelected: {
backgroundColor: theme.palette.action.selected,
},
}); });
const enhance = compose( const enhance = compose(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment