Fix tooltip rendering in wrong position on first mount

This commit is contained in:
Luke Vella 2022-04-16 10:05:40 +01:00
parent a48d75f45d
commit c1a3394a93
3 changed files with 15 additions and 8 deletions

View file

@ -7,6 +7,7 @@ import { requiredString } from "../../utils/form-validation";
import Button from "../button";
import CheckCircle from "../icons/check-circle.svg";
import NameInput from "../name-input";
import Tooltip from "../tooltip";
import { ControlledScrollDiv } from "./poll";
import { usePollContext } from "./poll-context";
import { ParticipantForm } from "./types";
@ -160,6 +161,7 @@ const ParticipantRowForm: React.VoidFunctionComponent<ParticipantRowFormProps> =
})}
</ControlledScrollDiv>
<div className="flex items-center px-2 space-x-2 transition-all">
<Tooltip content="Save" placement="top">
<Button
htmlType="submit"
icon={<CheckCircle />}
@ -167,6 +169,7 @@ const ParticipantRowForm: React.VoidFunctionComponent<ParticipantRowFormProps> =
loading={isSubmitting}
data-testid="submitNewParticipant"
/>
</Tooltip>
<Button onClick={onCancel} type="default">
Cancel
</Button>

View file

@ -91,7 +91,7 @@ const Tooltip: React.VoidFunctionComponent<TooltipProps> = ({
>
{children}
</div>
{portal && debouncedValue
{portal
? ReactDOM.createPortal(
<div
ref={setPopperElement}

View file

@ -124,6 +124,10 @@
[data-popper-placement="bottom"] .tooltip-arrow {
@apply bottom-full border-b-slate-700;
}
[data-popper-placement="top"] .tooltip-arrow {
@apply top-full border-t-slate-700;
}
}
@layer components {