Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 🐛 empty disabled Button align issue #22461

Merged
merged 2 commits into from Mar 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 5 additions & 1 deletion components/button/style/index.less
Expand Up @@ -227,8 +227,12 @@
}

// https://github.com/ant-design/ant-design/issues/12681
// same method as Select
&:empty {
vertical-align: top;
display: inline-block;
width: 0;
visibility: hidden;
content: '\a0';
}
}

Expand Down
Expand Up @@ -4,6 +4,7 @@ exports[`Tooltip rtl render component should be rendered correctly in RTL direct

exports[`Tooltip should hide when mouse leave antd disabled component Button 1`] = `
<span
class="ant-tooltip-disabled-compatible-wrapper"
style="display: inline-block; cursor: not-allowed;"
>
<button
Expand All @@ -17,6 +18,7 @@ exports[`Tooltip should hide when mouse leave antd disabled component Button 1`]

exports[`Tooltip should hide when mouse leave antd disabled component Checkbox 1`] = `
<span
class="ant-tooltip-disabled-compatible-wrapper"
style="display: inline-block; cursor: not-allowed;"
>
<label
Expand All @@ -42,6 +44,7 @@ exports[`Tooltip should hide when mouse leave antd disabled component Checkbox 1

exports[`Tooltip should hide when mouse leave antd disabled component Switch 1`] = `
<span
class="ant-tooltip-disabled-compatible-wrapper"
style="display: inline-block; cursor: not-allowed;"
>
<button
Expand Down
8 changes: 6 additions & 2 deletions components/tooltip/index.tsx
Expand Up @@ -74,7 +74,7 @@ const splitObject = (obj: any, keys: string[]) => {
// Fix Tooltip won't hide at disabled button
// mouse events don't trigger at disabled button in Chrome
// https://github.com/react-component/tooltip/issues/18
function getDisabledCompatibleChildren(element: React.ReactElement<any>) {
function getDisabledCompatibleChildren(element: React.ReactElement<any>, prefixCls: string) {
const elementType = element.type as any;
if (
(elementType.__ANT_BUTTON === true ||
Expand Down Expand Up @@ -110,7 +110,10 @@ function getDisabledCompatibleChildren(element: React.ReactElement<any>) {
className: null,
});
return (
<span style={spanStyle} className={element.props.className}>
<span
style={spanStyle}
className={classNames(element.props.className, `${prefixCls}-disabled-compatible-wrapper`)}
>
{child}
</span>
);
Expand Down Expand Up @@ -238,6 +241,7 @@ class Tooltip extends React.Component<TooltipProps, any> {

const child = getDisabledCompatibleChildren(
React.isValidElement(children) ? children : <span>{children}</span>,
prefixCls,
);

const childProps = child.props;
Expand Down