react-component / react-component/tooltip
transitionName animation doesn't work
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 944
- Forks
- 199
- Avg merge
- 19h 1m
- Merged PRs (30d)
- 3
Description
Hello!
I have an issue trying to add an animation to my component with transitionName prop. My code looks like this:
import * as React from "react";
import styled, { css } from "styled-components";
import RCTooltip from "rc-tooltip";
const TRANS_NAME = "rc-tooltip-zoom";
const overlapMixin = css``;
const Overlay = styled<{ overlap?: boolean }, "div">("div")`
opacity: 1;
transition: all 1s linear;
.rc-tooltip-zoom.rc-tooltip-hidden & {
opacity: 0;
transition: all 1s linear;
}
.rc-tooltip-zoom {
&-enter & {
opacity: 0;
}
&-enter-active & {
opacity: 0;
}
}
&-leave & {
opacity: 1;
}
&-leave-active & {
opacity: 0;
}
}
${({ overlap }) => overlap && overlapMixin};
`;
const overlayDefaultStyle: React.CSSProperties = {
position: "absolute",
};
export class Popover extends React.Component<any, {}> {
static defaultProps = {
placement: "right",
};
state = {
isVisible: true,
};
toggleVisibility = () => {
this.setState({
isVisible: !this.state.isVisible,
});
};
render() {
const { placement, anchor, offset, overlap, children } = this.props;
return (
<RCTooltip
overlayClassName={TRANS_NAME}
overlay={<Overlay overlap={overlap}>{children}</Overlay>}
trigger={["click"]}
visible={this.state.isVisible}
placement={placement}
align={{ offset }}
overlayStyle={overlayDefaultStyle}
transitionName={TRANS_NAME}
onVisibleChange={this.toggleVisibility}
>
{anchor}
</RCTooltip>
);
}
}
I want the <Overlay /> component to fade in and out as I click the anchor button. As I can see, I should give the tooltip's overlay (main positioned container) a classname and add styles (like in react-transition-group) on &-enter, &-enter-active, etc. But somehow, none of these classes seem to appear in DOM. Please, let me know if I got it wrong and it works differently.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the example and inspecting the rendered tooltip DOM while toggling visibility. Trace the transitionName prop through rc-tooltip's overlay rendering to determine why the expected enter and leave classes are absent; done means identifying the supported animation behavior or a specific change needed to make the classes appear.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react, typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 28/100