Skip to content

Commit c5b960b

Browse files
committed
Fixed checkbox flickering on initial label hover
* Changed lable to div and added a click handler
1 parent c6bd0c3 commit c5b960b

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

src/components/Columns.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,19 +35,21 @@ const Columns = ({
3535
className={ menuItemClassName }
3636
padding="0.25rem 0.75rem"
3737
styles={ styles.dropdownItem }
38-
htmlFor={ `rdt-columns-${name}-${index}` }
38+
onClick={(event) => {
39+
action(SET_VISIBLE_COLUMN_IDS)({ index, checked: !event.target.firstChild.checked, width })
40+
}}
3941
>
4042
<input
41-
id={ `rdt-columns-${name}-${index}` }
4243
name={ name }
4344
type="checkbox"
4445
style={{ margin: 5 }}
4546
checked={ -1 !== visibleColumnIds.indexOf(index) }
46-
onChange={(event) => (
47+
onClick={(event) => event.stopPropagation()}
48+
onChange={(event) => {
4749
action(SET_VISIBLE_COLUMN_IDS)({ index, checked: event.target.checked, width })
48-
)}
50+
}}
4951
/>
50-
<label>{ label }</label>
52+
{ label }
5153
</Dropdown.Item>
5254
))}
5355
</Dropdown.Menu>

src/styled-components/Dropdown.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ export const Menu = styled.div `
3737
`};
3838
`;
3939

40-
export const Item = styled.label `
41-
display: block;
40+
export const Item = styled.div `
4241
clear: both;
4342
text-align: inherit;
4443
white-space: nowrap;

0 commit comments

Comments
 (0)