remove workaround for missing event.relatedTarget
This commit is contained in:
parent
99662333e6
commit
7616b07f8e
|
@ -31,10 +31,9 @@ export const validator = (chill) => {
|
||||||
// so we first create the function, and then assign methods onto it
|
// so we first create the function, and then assign methods onto it
|
||||||
const action = (node) => {
|
const action = (node) => {
|
||||||
// trigger validation whenever focus goes from inside our node to outside our node
|
// trigger validation whenever focus goes from inside our node to outside our node
|
||||||
const on_blur = async (event) => {
|
const on_blur = (event) => {
|
||||||
// if validation messages aren't already enabled, check whether the new focused element is outside of our node
|
// if validation messages aren't already enabled, check whether the new focused element is outside of our node
|
||||||
// if event.relatedTarget is not available, wait 100ms and then use document.activeElement
|
if (!message_enabled && !node.contains(event.relatedTarget)) {
|
||||||
if (!message_enabled && !node.contains(event.relatedTarget || (await new Promise((res) => setTimeout(() => res(document.activeElement), 100))))) {
|
|
||||||
// enable displaying validation messages for this validator, and update the store
|
// enable displaying validation messages for this validator, and update the store
|
||||||
validate();
|
validate();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue