Skip to content

[BUG] Changing the content prop to a falsey value doesn't update the displayed content #875

@phoenixeliot

Description

@phoenixeliot

Describe the bug
If you control the content prop with conditional logic, only the initial value is used for the actual display content.

Version of Package
v5.3.0

To Reproduce
Create a tooltip like so:

const [state, setState] = useState(true);

return (
  <>
    <div id="some-id" onClick={() => setState(!state)}>text</div>
    <Tooltip anchorId="some-id" content={state ? 'some content' : ''}/>
  </>
)

Expected behavior
Changing the content prop should cause the displayed tooltip to change to '' (no tooltip). Instead, it will stay as "some content" in the above example regardless of the value of state

Screenshots
None for now.

Desktop (please complete the following information if possible or delete this section):

  • OS: macOS
  • Browser: Brave (Chromium-based)
  • Version 1.46.144

Additional context
This is a real blocker for me because if I try to use the content="." hack to fix #872 and use children for the conditional instead, then if my conditional returns null, then a tooltip is shown with that period in it instead of nothing, like I want. So there is no way to show conditional logic that might return null, so there is no way to conditionally disable a tooltip that I know of.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions