Browse Source

fix(Button): button's children should be disabled when button is disabled (#42949)

* fix: button's children should be disabled when button is disabled

* feat: update test case

* feat: update test case
pull/42965/head
kiner-tang(文辉) 1 year ago
committed by GitHub
parent
commit
f0a94139e7
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 9
      components/button/__tests__/index.test.tsx
  2. 4
      components/button/style/index.ts

9
components/button/__tests__/index.test.tsx

@ -334,4 +334,13 @@ describe('Button', () => {
);
expect(wrapper.container.firstChild).toMatchSnapshot();
});
it("should prevent children's event when button is disabled", () => {
const { container } = render(
<Button disabled>
<a id="link">test</a>
</Button>,
);
expect(window.getComputedStyle(container.querySelector('#link')!).pointerEvents).toBe('none');
});
});

4
components/button/style/index.ts

@ -38,6 +38,10 @@ const genSharedButtonStyle: GenerateStyle<ButtonToken, CSSObject> = (token): CSS
lineHeight: token.lineHeight,
color: token.colorText,
'&:disabled > *': {
pointerEvents: 'none',
},
'> span': {
display: 'inline-block',
},

Loading…
Cancel
Save