-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: focus the slider on mousedown (#63)
- Loading branch information
1 parent
651dbc2
commit 602962c
Showing
2 changed files
with
8 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
602962c
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.
@web-padawan This is a breaking change :(
I am using your great library and its
rgba-string-color-picker
element in association with an input field. When the input has the focus, I display the color picker. When the input field loses focus (blur event), I hide the color picker. Before this patch, when a slider was moving in the color picker, the focus was remaining on the input field thus keeping the picker opened. With your change, the slider is taking the focus from the input field as soon as we use the color picker.Any suggestions?
602962c
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.
Hi, sorry about that, I didn't consider this use case. As a workaround, you could check the
event.relatedTarget
onfocusout
event, to detect whether focus moves to the color picker or not. I will create a code example tomorrow.602962c
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.
@web-padawan Thanks for your help. Using
event.relatedTarget
I can detect if the picker get the focus and prevent hiding it. However, once the picker has the focus, detecting whether a click is made outside the picker element (before hiding it) requires yet another logic.602962c
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.
I agree it's a bit complicated. Here is the full example using two
focusout
listeners.Sorry about the delay. I'm going to add this example and maybe some more examples to README soon.
602962c
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.
Thanks a lot for the full example.