Skip to content

AnnounceKit badge doesn't disappear on click when ref is used #30

@stephan-noel-primer

Description

@stephan-noel-primer

The following, when clicking on the element I pass open to (for its onClick handler), the badge is still shown until I refresh the page:

const AnnounceKitBadge = ({ children }) => {
  const announceKitRef = useRef<AnnounceKit>();

  const open = async () => await announceKitRef?.current?.open();

  const AnnounceKitElement = (
    <AnnounceKit
      widget={'myurl'}
      ref={announceKitRef}
    />
  );

  return children({ open, AnnounceKitElement }) ;
};

It will only disappear as expected if I were to click directly on the small circle badge instead of clicking on the element I pass the open function to as an onClick handler. This ref usage is in the example codesandbox so I'd expect it to work.

When I use catchClick and pass a selector instead of the onClick event handler, then clicking on the element I pass the selector to will make the badge disappear upon open as expected..

A related issue is passing children to AnnounceKit isn't well supported since there is no way to override the styles, the display: inline is hardcoded. Passing widgetStyle doesn't help either.

I'm using version 2.1.7.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions