Skip to content

Commit

Permalink
fix(react-grid): use correct cursors for dragging (#224)
Browse files Browse the repository at this point in the history
  • Loading branch information
gsobolev authored Jul 26, 2017
1 parent 786206d commit 6269063
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export const Container = ({
<ul
className="list-group"
style={{
cursor: 'move',
position: 'fixed',
zIndex: 1000,
left: 0,
Expand Down
23 changes: 23 additions & 0 deletions packages/dx-react-grid-bootstrap3/src/templates/drag-drop.test.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import React from 'react';
import { mount } from 'enzyme';
import { Container } from './drag-drop';

describe('Container', () => {
it('should have correct styles', () => {
const tree = mount(
<Container
columns={[{
name: 'Test',
}]}
clientOffset={{ x: 10, y: 20 }}
columnTemplate={() => <div />}
/>,
);

expect(tree.find('ul').prop('style'))
.toMatchObject({
transform: 'translate(calc(10px - 50%), calc(20px - 50%))',
cursor: 'move',
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,7 @@ export class TableHeaderCell extends React.PureComponent {
MozUserSelect: 'none',
WebkitUserSelect: 'none',
} : {}),
...(allowDragging ? { cursor: 'move' } : {}),
...(allowSorting ? { cursor: 'pointer' } : {}),
...(allowSorting || allowDragging ? { cursor: 'pointer' } : null),
...(dragging || column.isDraft ? { opacity: 0.3 } : null),
...style,
}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ describe('TableHeaderCell', () => {
userSelect: 'none',
MozUserSelect: 'none',
WebkitUserSelect: 'none',
cursor: 'move',
cursor: 'pointer',
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ import PropTypes from 'prop-types';
import { Paper, Typography } from 'material-ui';
import { withStyles, createStyleSheet } from 'material-ui/styles';

const styleSheet = createStyleSheet('DragDrop', theme => ({
export const styleSheet = createStyleSheet('DragDrop', theme => ({
container: {
cursor: 'move',
position: 'fixed',
zIndex: 1000,
left: 0,
Expand Down Expand Up @@ -50,7 +51,7 @@ ContainerBase.propTypes = {

export const Container = withStyles(styleSheet)(ContainerBase);

export const ColumnBase = ({ column, classes }) => (
const ColumnBase = ({ column, classes }) => (
<Typography
className={classes.column}
type="body1"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import React from 'react';
import { Paper } from 'material-ui';
import { mountWithStyles } from '../utils/testing';
import { Container, styleSheet } from './drag-drop';

describe('Container', () => {
it('should have correct styles', () => {
const { tree, classes } = mountWithStyles(
<Container
columns={[{
name: 'Test',
}]}
clientOffset={{ x: 10, y: 20 }}
columnTemplate={() => <div />}
/>,
styleSheet,
);

expect(tree.find(Paper).hasClass(classes.container))
.toBeTruthy();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export const styleSheet = createStyleSheet('TableHeaderCell', theme => ({
width: '100%',
},
cellDraggable: {
cursor: 'move',
cursor: 'pointer',
},
cellClickable: {
cursor: 'pointer',
Expand Down

0 comments on commit 6269063

Please sign in to comment.