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

View file

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

View file

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