fix: Radio cannot use Tooltip (#27050)

resolve #26921
resolve #25222

close #26929
This commit is contained in:
偏右 2020-10-09 18:01:04 +08:00 committed by GitHub
parent f812855122
commit 7662160880
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 3 deletions

View File

@ -7,7 +7,7 @@ import RadioGroupContext from './context';
import { composeRef } from '../_util/ref';
import devWarning from '../_util/devWarning';
const InternalRadio: React.ForwardRefRenderFunction<unknown, RadioProps> = (props, ref) => {
const InternalRadio: React.ForwardRefRenderFunction<HTMLElement, RadioProps> = (props, ref) => {
const context = React.useContext(RadioGroupContext);
const { getPrefixCls, direction } = React.useContext(ConfigContext);
const innerRef = React.useRef<HTMLElement>();
@ -37,8 +37,8 @@ const InternalRadio: React.ForwardRefRenderFunction<unknown, RadioProps> = (prop
radioProps.disabled = props.disabled || context.disabled;
}
const wrapperClassString = classNames(
`${prefixCls}-wrapper`,
{
[`${prefixCls}-wrapper`]: true,
[`${prefixCls}-wrapper-checked`]: radioProps.checked,
[`${prefixCls}-wrapper-disabled`]: radioProps.disabled,
[`${prefixCls}-wrapper-rtl`]: direction === 'rtl',
@ -54,13 +54,14 @@ const InternalRadio: React.ForwardRefRenderFunction<unknown, RadioProps> = (prop
onMouseEnter={props.onMouseEnter}
onMouseLeave={props.onMouseLeave}
>
<RcCheckbox {...radioProps} prefixCls={prefixCls} ref={mergedRef as any} />
<RcCheckbox {...radioProps} prefixCls={prefixCls} ref={mergedRef} />
{children !== undefined ? <span>{children}</span> : null}
</label>
);
};
const Radio = React.forwardRef<unknown, RadioProps>(InternalRadio);
Radio.displayName = 'Radio';
Radio.defaultProps = {

View File

@ -185,6 +185,7 @@ span.@{radio-prefix-cls} + * {
position: absolute;
top: 0;
left: 0;
z-index: -1;
width: 100%;
height: 100%;
}