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
This commit is contained in:
kiner-tang(文辉) 2023-06-12 10:22:32 +08:00 committed by GitHub
parent 0e520f730a
commit f0a94139e7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 0 deletions

View File

@ -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');
});
});

View File

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