mirror of
https://github.com/ant-design/ant-design.git
synced 2024-11-27 20:49:53 +08:00
fix: fix float-button findDOMNode error (#48865)
This commit is contained in:
parent
1f39811047
commit
c9f7f5d8e6
@ -2,6 +2,7 @@ import React, { useContext, useEffect, useState } from 'react';
|
||||
import VerticalAlignTopOutlined from '@ant-design/icons/VerticalAlignTopOutlined';
|
||||
import classNames from 'classnames';
|
||||
import CSSMotion from 'rc-motion';
|
||||
import { composeRef } from 'rc-util/es/ref';
|
||||
|
||||
import getScroll from '../_util/getScroll';
|
||||
import scrollTo from '../_util/scrollTo';
|
||||
@ -87,9 +88,9 @@ const BackTop = React.forwardRef<FloatButtonRef, BackTopProps>((props, ref) => {
|
||||
|
||||
return (
|
||||
<CSSMotion visible={visible} motionName={`${rootPrefixCls}-fade`}>
|
||||
{({ className: motionClassName }) => (
|
||||
{({ className: motionClassName }, setRef) => (
|
||||
<FloatButton
|
||||
ref={internalRef}
|
||||
ref={composeRef(internalRef, setRef)}
|
||||
{...contentProps}
|
||||
onClick={scrollToTop}
|
||||
className={classNames(className, motionClassName)}
|
||||
|
@ -8,6 +8,8 @@ import { fireEvent, render, waitFakeTimer } from '../../../tests/utils';
|
||||
const { BackTop } = FloatButton;
|
||||
|
||||
describe('BackTop', () => {
|
||||
const errSpy = jest.spyOn(console, 'error').mockImplementation(() => {});
|
||||
|
||||
beforeEach(() => {
|
||||
jest.useFakeTimers();
|
||||
});
|
||||
@ -55,7 +57,6 @@ describe('BackTop', () => {
|
||||
});
|
||||
|
||||
it('no error when BackTop work', () => {
|
||||
const errSpy = jest.spyOn(console, 'error').mockImplementation(() => {});
|
||||
render(<BackTop visibilityHeight={0} />);
|
||||
expect(errSpy).not.toHaveBeenCalled();
|
||||
errSpy.mockRestore();
|
||||
|
Loading…
Reference in New Issue
Block a user