Browse Source

fix: Radio cannot use Tooltip (#27050)

resolve #26921
resolve #25222

close #26929
pull/27043/merge
偏右 4 years ago
committed by GitHub
parent
commit
7662160880
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 7
      components/radio/radio.tsx
  2. 1
      components/radio/style/index.less

7
components/radio/radio.tsx

@ -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 = {

1
components/radio/style/index.less

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

Loading…
Cancel
Save