charkour / react-reactions

😲 Create custom reaction pickers and counters or use your favorites!
MIT License
76 stars 16 forks source link

Closing the selector when clicked outside of the react-reactions component. #121

Closed gj1118 closed 2 years ago

gj1118 commented 2 years ago

Hi, Thanks for this awesome library.Much appreciated. 🙏🏽

That said, I have a question please - can I hide the Selector if I clicked anywhere else without selecting any emoji?? I have tried following some articles on SO, but it seems none of them are working. Some guidance here will be very well appreciated.

Thanks...

charkour commented 2 years ago

Hey, that should be possible. I can get an example to you in the next day or so.

Which component are you using and how are you controlling if it is opened or closed?

gj1118 commented 2 years ago

Awesome. thanks for all the help, kind Sir.

Here is how I am using it at this moment.

  <SlackCounter
    counters={reactions.length === 0 ? reactionList : reactions}
    user={props.userInformation ? props.userInformation.username : "You"}
    onSelect={clickSelectedEmoji}
    onAdd={(e) => setShowReactions(true)}
  />
  {showReactions && (
    <SlackSelector
      active="mine"
      scrollHeight={300}
      removeEmojis={[]}
      frequent={[
        "👍",
        "🐉",
        "🙌",
        "🤦‍♀️",
        "😊",
        "🐬",
        "😹",
        "👻",
        "🚀",
        "🥶",
        "🤡",
        "🇨🇦",
      ]}
      onSelect={(e) => {
        handleSelect(e);
        setShowReactions(false);
      }}
    />
  )}

Please let me know if you need some more information please.

One more request please 🙏🏽 It seems that the SlackSelector is not sitting on top of other cotnrols. I tried to control it via css by setting the z-index, but it apparently wont work. Here is a screenshot please

image

Notice that the Slack selector has pushed down the card thereby increasing its height. It should have been on top of the underlying card. Also if this was on top , it would not have got cut off on the right hand side. I am not setting the z-index anywhere else.

Please let me know what you think.

Thank you once again for your time and patience.

Warm Regards!!

charkour commented 2 years ago

Hi @gj1118,

I found a stack overflow post that adds an event listener that will respond to user clicks. It is important to note that a <div> surrounds the <SlackSelector> and has a width set. We can attach a ref to that <div>. Checkout this stackblitz.

Does this solve your issue?

It seems that the SlackSelector is not sitting on top of other cotnrols. I tried to control it via css by setting the z-index, but it apparently wont work.

Would you be willing to give me a stackblitz or code sandbox that reproduces the issue? It would be easier for me to help if I can see the exact problem! Thank you! And warm regards.

gj1118 commented 2 years ago

Thanks Charles, I will take a look and confirm a bit later please, if that is ok with you.

Thanks a lot for your help.

With Regards Gagan Janjua

On Mon, Jan 24, 2022 at 12:44 PM Charles Kornoelje @.***> wrote:

Hi @gj1118 https://github.com/gj1118,

I found a stack overflow post that adds an event listener that will respond to user clicks. It is important to note that a

surrounds the and has a width set. We can attach a ref to that
. Checkout this stackblitz https://stackblitz.com/edit/react-ts-e7x6mv?file=index.tsx.

Does this solve your issue?

It seems that the SlackSelector is not sitting on top of other cotnrols. I tried to control it via css by setting the z-index, but it apparently wont work.

Would you be willing to give me a stackblitz or code sandbox that reproduces the issue? It would be easier for me to help if I can see the exact problem! Thank you! And warm regards.

— Reply to this email directly, view it on GitHub https://github.com/charkour/react-reactions/issues/121#issuecomment-1020369725, or unsubscribe https://github.com/notifications/unsubscribe-auth/AADTQDNFGOUFWHEL6ASB2BDUXWFYVANCNFSM5MMLDWRA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you were mentioned.Message ID: @.***>

charkour commented 2 years ago

Thanks, that is okay with me. Thanks for your patience!

With regards

charkour commented 2 years ago

Closing this issue. See slackblitz link for solution.