ooade / react-click-away-listener Goto Github PK
View Code? Open in Web Editor NEW:paw_prints: Tiny React Click Away Listener built with React Hooks
License: MIT License
:paw_prints: Tiny React Click Away Listener built with React Hooks
License: MIT License
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>
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?
We should make onClick
the default mouse event, and onTouchEnd
the default touch event.
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.
I've updated from React 16.14.0 to React 17.0.2 and now it seems like click event listener component triggers whenever it's mounted. This made a component i created no longer work.
Can you check this?
Describe the bug
react-click-away-listener
.Tab
key.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):
Smartphone (please complete the following information):
๐
Additional context
I try to use focusEvent="none"
to disable. It works now. But not good.
When we "add react-click-away-listener" to some element on page and have some iframe on this page, after click on iframe - listener doesn't triggered.
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.
Do you have any plans for supporting portals?
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>
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
?
Is there a way to add a flag that also right click events should trigger the clickAway handler?
does not work with react 18 ?
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:
Expected behavior
A clear and concise description of what you expected to happen.
Screenshots
If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):
Smartphone (please complete the following information):
Additional context
Add any other context about the problem here.
Currently, children are wrapped around div. We should be able to specify the element to wrap the children. I have submitted a PR if you think this is valid
Describe the bug
A clear and concise description of what the bug is.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
onClickAway not trigger
Chrome
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.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.