Giter Club home page Giter Club logo

react-click-away-listener's Issues

Memory Leak

The react-click-away-listener fires the following memory leak FYI.

Warning: Can't perform a React state update on an unmounted component. This is a no-op, but it indicates a memory leak in your application. To fix, cancel all subscriptions and asynchronous tasks in a useEffect cleanup function.
Header@webpack-internal:///./components/modules/Header.tsx:24:74
div
Default@webpack-internal:///./components/layouts/Default/Default.tsx:22:18

overrideMethod react_devtools_backend.js:2557
    React 5
    handleClickAway Header.tsx:18
    handleEvents ClickAwayListener.tsx:92
    (Async: EventListener.handleEvent)
    ClickAwayListener ClickAwayListener.tsx:95

It's implemented as below:

<ClickAwayListener onClickAway={handleClickAway}>
  <button type="button" 
    onClick={() => {
      setOpenProfile(!openProfile);
    }}>
      <span>See Profile</span>
    </button>
</ClickAwayListener>

v1.1.0 does not appear to be passing Event

Hi Again!

v1.1.0 does not appear to be passing the event to the onClickAway function. I copied the source to my application and it seems to be fine. I'm wondering if perhaps there was an issue with the build process. I do have the updates types!

Would you be able to take a look into this?

Add classname to the returned element

Currently the click away listener doesn't have a class name and adds a naked element. There should be a classname before props are spread to indicate in dev tools that this naked element is actually the click away listener. Since props are spread any classname that is provided will override it. This will just help clarify what this naked element is when no classname prop is provided.

Let click-away event do not report if we click / focus the children of the element.

Describe the bug

  1. When I click a button, the website will show me a list. And it uses react-click-away-listener.
  2. I want to choose one clickable element by my Tab key.
  3. Ok. Now I choose it - a child of the list.
  4. Oh no. The list get the click-away event and close itself - and its children.

To Reproduce
๐Ÿ‘€

Expected behavior
I hope if I try to focus the children, (even click the children), it will never get the click-away event.

Screenshots
๐Ÿ‘€

Desktop (please complete the following information):

  • OS: Manjaro
  • Browser Firefox
  • Version 99.0.1

Smartphone (please complete the following information):
๐Ÿ‘€

Additional context
I try to use focusEvent="none" to disable. It works now. But not good.

Click inside of div on react-icons icon calls OnClickAway

image
When I click on these items, the popup is closed, but it shouldn't be. For example if I click on the embed code copy button then the menu should remain open.

<ClickAwayListener onClickAway={() => mapDetailsOpen && setMapDetailsOpen(false)}>
  <div></div>
</ClickAwayListener/>

Using the latest pre-react 17 version that I could find, 1.4.4.

Portal

Do you have any plans for supporting portals?

Warning when used within a form

image

Building a custom select dropdown with ClickAwayListener wrapping the component.

Right now the structure looks something like this

<form onSubmit={e => e.preventDefault()}>
       <ClickAwayListener>
               <button onClick={e => e.preventDefault()}> test </button>
       </ClickAwayListener>
       <button type='submit'>submit</button>
</form>

v2.2.0 introduced a breaking change by dropping React 17 support

Describe the bug

In #59 a change has been introduced that changes peerDependencies of react and react-dom to only allow versions ^18.0.0. This introduced a breaking change by dropping support for React 17.

I suggest setting peerDependencies to ^17.0.0 || ^18.0.0 to fix a breaking change.

And actually, while we're at it, it looks like your code should run perfectly in ^16.8.0 as well. So perhaps even set it to ^16.8.0 || ^17.0.0 || ^18.0.0?

an error appear in console when you add touchEvent

Describe the bug
A clear and concise description of what the bug is.
the bug is some error appear in console when you add touchEvent

To Reproduce
Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

image

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.
image

Desktop (please complete the following information):

  • OS: [e.g. iOS] windows
  • Browser [e.g. chrome, safari] chrome
  • Version [e.g. 22] 100

Smartphone (please complete the following information):

  • Device: [e.g. iPhone6]
  • OS: [e.g. iOS8.1]
  • Browser [e.g. stock browser, safari]
  • Version [e.g. 22]

Additional context
Add any other context about the problem here.

OnClickAway trigger when I switch browser tab

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:

  1. switch tab
  2. back to current tab
  3. onClickAway triggerd

Expected behavior
onClickAway not trigger

Chrome

onClickAway should return the fired event

Currently the Mouse/Touch Event that is fired from clicking away is not passed to the function passed for onClickAway.

I feel this should be changed so that you could prevent event bubbling by using event.preventDefault or to do other stuff with the event.

I can submit a PR if you wish.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.