Skip to content

Commit 0122707

Browse files
committed
fix(Checkbox): add label cursor
1 parent d2054f1 commit 0122707

File tree

3 files changed

+42
-2
lines changed

3 files changed

+42
-2
lines changed

src/checkbox/main.scss

+3
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,9 @@
123123
border-color: $checkbox-hovered-border-color;
124124
background-color: $checkbox-hovered-bg-color;
125125
}
126+
#{$checkbox-prefix}-label {
127+
cursor: pointer;
128+
}
126129
}
127130

128131
&.indeterminate:not(.disabled):hover,

src/radio/main.scss

+4-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
width: $radio-width;
2323
height: $radio-width;
2424
margin: 0;
25+
cursor: pointer;
2526
}
2627
}
2728

@@ -108,6 +109,9 @@
108109
border-color: $radio-hovered-border-color;
109110
background-color: $radio-hovered-bg-color;
110111
}
112+
#{$radio-prefix}-label {
113+
cursor: pointer;
114+
}
111115
}
112116

113117
&.checked:not(.disabled):hover,
@@ -274,7 +278,6 @@
274278
top: 0;
275279
left: 0;
276280
margin: 0;
277-
cursor: pointer;
278281
}
279282
}
280283
&-group {

test/radio/a11y-spec.js

+35-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React from 'react';
2-
import Enzyme from 'enzyme';
2+
import Enzyme, { mount } from 'enzyme';
33
import Adapter from 'enzyme-adapter-react-16';
4+
import assert from 'power-assert';
45
import Radio from '../../src/radio/index';
56
import '../../src/radio/style';
67
import { unmount, testReact } from '../util/a11y/validate';
@@ -98,4 +99,37 @@ describe('Radio A11y', () => {
9899
);
99100
return wrapper;
100101
});
102+
103+
it('should add tabIndex for first Radio Item', async () => {
104+
const wrapper = mount(
105+
<Radio.Group >
106+
<Radio id="pear" value="pear" checked>={true}
107+
梨子
108+
</Radio>
109+
<Radio id="apple" value="apple" className="apple">
110+
苹果
111+
</Radio>
112+
</Radio.Group>
113+
);
114+
wrapper.update();
115+
assert(wrapper.find("input#pear").at(0).getDOMNode().tabIndex === 0);
116+
});
117+
118+
it('should not add tabIndex for non Radio Item', async () => {
119+
const wrapper = mount(
120+
<Radio.Group defaultValue={'pear'} >
121+
<div id="mywrapper" >
122+
<Radio id="pear" value="pear">
123+
梨子
124+
</Radio>
125+
</div>
126+
<div id='another' tabIndex="-100">
127+
<Radio id="apple" value="apple" className="apple">
128+
苹果
129+
</Radio>
130+
</div>
131+
</Radio.Group>
132+
);
133+
assert(wrapper.find("div#mywrapper").at(0).getDOMNode().tabIndex === -1);
134+
});
101135
});

0 commit comments

Comments
 (0)