Skip to content

Commit

Permalink
Fix clicks on sticker picker buttons to page left/right
Browse files Browse the repository at this point in the history
  • Loading branch information
scottnonnenberg-signal committed Aug 5, 2019
1 parent 2beb421 commit 6b6da04
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion ts/components/stickers/StickerButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,18 @@ export const StickerButton = React.memo(
setPopperRoot(root);
document.body.appendChild(root);
const handleOutsideClick = ({ target }: MouseEvent) => {
if (!root.contains(target as Node)) {
const targetElement = target as HTMLElement;
const className = targetElement
? targetElement.className || ''
: '';

// We need to special-case sticker picker header buttons, because they can
// disappear after being clicked, which breaks the .contains() check below.
const isMissingButtonClass =
!className ||
className.indexOf('module-sticker-picker__header__button') < 0;

if (!root.contains(targetElement) && isMissingButtonClass) {
setOpen(false);
}
};
Expand Down

0 comments on commit 6b6da04

Please sign in to comment.