Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: do not wrap the whole function in the event wrapper
Closes #387
- Loading branch information
1 parent
8161fa2
commit 479e85b
Showing
10 changed files
with
16 additions
and
40 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,14 @@ | ||
import {fireEvent} from '@testing-library/dom' | ||
import {getActiveElement, isFocusable, wrapInEventWrapper} from './utils' | ||
import {getActiveElement, isFocusable, eventWrapper} from './utils' | ||
|
||
function blur(element, init) { | ||
if (!isFocusable(element)) return | ||
|
||
const wasActive = getActiveElement(element.ownerDocument) === element | ||
if (!wasActive) return | ||
|
||
element.blur() | ||
eventWrapper(() => element.blur()) | ||
fireEvent.focusOut(element, init) | ||
} | ||
|
||
blur = wrapInEventWrapper(blur) | ||
|
||
export {blur} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,14 @@ | ||
import {fireEvent} from '@testing-library/dom' | ||
import {getActiveElement, isFocusable, wrapInEventWrapper} from './utils' | ||
import {getActiveElement, isFocusable, eventWrapper} from './utils' | ||
|
||
function focus(element, init) { | ||
if (!isFocusable(element)) return | ||
|
||
const isAlreadyActive = getActiveElement(element.ownerDocument) === element | ||
if (isAlreadyActive) return | ||
|
||
element.focus() | ||
eventWrapper(() => element.focus()) | ||
fireEvent.focusIn(element, init) | ||
} | ||
focus = wrapInEventWrapper(focus) | ||
|
||
export {focus} |
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
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
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