Skip to content

Commit

Permalink
fix(Checkbox): add label cursor
Browse files Browse the repository at this point in the history
  • Loading branch information
guanpu committed Jun 16, 2019
1 parent d2054f1 commit 0122707
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 2 deletions.
3 changes: 3 additions & 0 deletions src/checkbox/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@
border-color: $checkbox-hovered-border-color;
background-color: $checkbox-hovered-bg-color;
}
#{$checkbox-prefix}-label {
cursor: pointer;
}
}

&.indeterminate:not(.disabled):hover,
Expand Down
5 changes: 4 additions & 1 deletion src/radio/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
width: $radio-width;
height: $radio-width;
margin: 0;
cursor: pointer;
}
}

Expand Down Expand Up @@ -108,6 +109,9 @@
border-color: $radio-hovered-border-color;
background-color: $radio-hovered-bg-color;
}
#{$radio-prefix}-label {
cursor: pointer;
}
}

&.checked:not(.disabled):hover,
Expand Down Expand Up @@ -274,7 +278,6 @@
top: 0;
left: 0;
margin: 0;
cursor: pointer;
}
}
&-group {
Expand Down
36 changes: 35 additions & 1 deletion test/radio/a11y-spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react';
import Enzyme from 'enzyme';
import Enzyme, { mount } from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
import assert from 'power-assert';
import Radio from '../../src/radio/index';
import '../../src/radio/style';
import { unmount, testReact } from '../util/a11y/validate';
Expand Down Expand Up @@ -98,4 +99,37 @@ describe('Radio A11y', () => {
);
return wrapper;
});

it('should add tabIndex for first Radio Item', async () => {
const wrapper = mount(
<Radio.Group >
<Radio id="pear" value="pear" checked>={true}
梨子
</Radio>
<Radio id="apple" value="apple" className="apple">
苹果
</Radio>
</Radio.Group>
);
wrapper.update();
assert(wrapper.find("input#pear").at(0).getDOMNode().tabIndex === 0);
});

it('should not add tabIndex for non Radio Item', async () => {
const wrapper = mount(
<Radio.Group defaultValue={'pear'} >
<div id="mywrapper" >
<Radio id="pear" value="pear">
梨子
</Radio>
</div>
<div id='another' tabIndex="-100">
<Radio id="apple" value="apple" className="apple">
苹果
</Radio>
</div>
</Radio.Group>
);
assert(wrapper.find("div#mywrapper").at(0).getDOMNode().tabIndex === -1);
});
});

0 comments on commit 0122707

Please sign in to comment.