-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(events): add eventStack #1733
Conversation
@levithomason Would be awesome to hear your throughts. However, I want to finish my other open PRs before I'll start there. |
src/lib/eventPool.js
Outdated
|
||
unlisten = name => { | ||
if(_.some(this.queues, name)) return | ||
document.removeEventListener(name, this.emit(name)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The emit
method returns a new function on each call. Are you sure this removes the original listener(s)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@davezuko Yep, you're fully right there. I pushed some changes and tests, now it works as I described.
Codecov Report
@@ Coverage Diff @@
## master #1733 +/- ##
=========================================
- Coverage 99.8% 99.8% -0.01%
=========================================
Files 148 148
Lines 2589 2555 -34
=========================================
- Hits 2584 2550 -34
Misses 5 5
Continue to review full report at Codecov.
|
src/modules/Dropdown/Dropdown.js
Outdated
} | ||
document.addEventListener('keydown', this.removeItemOnBackspace) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
moveSelectionOnKeyDown
, selectItemOnEnter
and removeItemOnBackspace
should be added only if the Dropdown
is open
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removeItemOnBackspace
works when a multiple search selection
Dropdown is focused and openOnFocus={false}
. The cursor focusses the Dropdown, it does not open, but the backspace listener is added so the user can remove labels:
I'd prefer we don't change any logic in this PR except the adding/removing events. That said, it looks like we're missing a test for this as well. Changing that logic should have broken a test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@levithomason Thanks for clarification, I've restored event handlers and added a fix. Now eventPull
handles only unique events
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@davezuko @levithomason I've performed final updates there, will be awesome to get a feedback there.
2707a7d
to
d0ab43a
Compare
I believe this also solves #1157, correct? |
No, #1157 will need an another solution, however this PR opens the road to it. |
I have not gone into this in detail yet, but I don't want to hold it up any longer so I'd like to merge it. One nit I have is that a pool, in my experience, is a set of shared resources where any available item may be pulled form the pool (like a db connection). I'd like to call this a "stack", which indicates they will be processed one at a time If so, let's go with EDIT Fix stack description, thanks David. |
I will change tomorrow and will sync with |
I merged with |
I think you mean a |
Hey there. Thanks for fixing this issue. I was wondering if this will be merged and released in the near future? It would help my team out with a current production bug. If there is anything I can contribute to get this merged, happy to help. :) |
Whoops, I still mean a stack, however, I was lazy and inaccurate in the description. I meant to say "processed one at a time, from the end" rather than "in the order added". When I imagine a Popup opening inside of a Modal, I think of a stack of handlers. The Popup handlers should be processed first even though they were added last. In a queue, I'd think the Modal handlers would be processed first, then the Popup (in the order they were added). Thanks for pointing out the error @davezuko. |
Released in |
Rel #284.
Fixes #1657.
What is it?
This PR introduces a new event handling system that will solve following problems:
Modal
s andDropdown
s);Dropdown
s;Example