Skip to content

Commit 092ddd2

Browse files
authored
refactor: move onChange event up (#372)
1 parent 2d11be0 commit 092ddd2

File tree

2 files changed

+7
-10
lines changed

2 files changed

+7
-10
lines changed

src/Step.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -128,11 +128,7 @@ export default function Step(props: StepProps) {
128128
);
129129

130130
const wrapperNode = (
131-
<div
132-
className={cls(`${itemCls}-wrapper`, classNames.itemWrapper)}
133-
style={styles.itemWrapper}
134-
{...accessibilityProps}
135-
>
131+
<div className={cls(`${itemCls}-wrapper`, classNames.itemWrapper)} style={styles.itemWrapper}>
136132
<div className={cls(`${itemCls}-icon`, classNames.itemIcon)} style={styles.itemIcon}>
137133
{iconRender?.(renderInfo)}
138134
</div>
@@ -170,6 +166,7 @@ export default function Step(props: StepProps) {
170166
let stepNode: React.ReactNode = (
171167
<div
172168
{...restItemProps}
169+
{...accessibilityProps}
173170
className={classString}
174171
style={{
175172
...styles.item,

tests/index.test.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -210,9 +210,9 @@ describe('Steps', () => {
210210
]}
211211
/>,
212212
);
213-
const items = container.querySelectorAll('.rc-steps-item-wrapper');
213+
const items = container.querySelectorAll('.rc-steps-item');
214214
fireEvent.click(items[1]);
215-
expect(onChange).toBeCalledWith(1);
215+
expect(onChange).toHaveBeenCalledTimes(1);
216216
});
217217

218218
it('items out of render function', () => {
@@ -233,7 +233,7 @@ describe('Steps', () => {
233233
<Steps current={current} onChange={onChange} items={items} key={current} />,
234234
);
235235

236-
const step = container.querySelectorAll('.rc-steps-item-wrapper')[1];
236+
const step = container.querySelectorAll('.rc-steps-item')[1];
237237
fireEvent.click(step);
238238
rerender(<Steps current={current} onChange={onChange} items={items} key={current} />);
239239
expect(container.querySelectorAll('.rc-steps-item')[1].classList).toContain(
@@ -265,7 +265,7 @@ describe('Steps', () => {
265265
/>,
266266
);
267267

268-
const btn = container.querySelectorAll('.rc-steps-item-wrapper')[0];
268+
const btn = container.querySelectorAll('.rc-steps-item')[0];
269269
fireEvent.click(btn);
270270
expect(onClick).toHaveBeenCalled();
271271
});
@@ -276,7 +276,7 @@ describe('Steps', () => {
276276
<Steps onChange={onChange} items={[{}, {}, { disabled: true }]} />,
277277
);
278278

279-
const items = container.querySelectorAll('.rc-steps-item-wrapper');
279+
const items = container.querySelectorAll('.rc-steps-item');
280280
fireEvent.click(items[2]);
281281
expect(onChange).not.toBeCalled();
282282
});

0 commit comments

Comments
 (0)