Skip to content

Commit 5f72dbc

Browse files
authored
Revert "fix(cdk/testing): simulate focusin/focusout events" (#23794)
This reverts commit ef7d9e0.
1 parent 399bff2 commit 5f72dbc

File tree

1 file changed

+3
-12
lines changed

1 file changed

+3
-12
lines changed

Diff for: src/cdk/testing/testbed/fake-events/element-focus.ts

+3-12
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,11 @@ function triggerFocusChange(element: HTMLElement, event: 'focus' | 'blur') {
1414
element.addEventListener(event, handler);
1515
element[event]();
1616
element.removeEventListener(event, handler);
17-
18-
// Some browsers won't move focus if the browser window is blurred while other will move it
19-
// asynchronously. If that is the case, we fake the event sequence as a fallback.
2017
if (!eventFired) {
21-
simulateFocusSequence(element, event);
18+
dispatchFakeEvent(element, event);
2219
}
2320
}
2421

25-
/** Simulates the full event sequence for a focus event. */
26-
function simulateFocusSequence(element: HTMLElement, event: 'focus' | 'blur') {
27-
dispatchFakeEvent(element, event);
28-
dispatchFakeEvent(element, event === 'focus' ? 'focusin' : 'focusout');
29-
}
30-
3122
/**
3223
* Patches an elements focus and blur methods to emit events consistently and predictably.
3324
* This is necessary, because some browsers can call the focus handlers asynchronously,
@@ -37,8 +28,8 @@ function simulateFocusSequence(element: HTMLElement, event: 'focus' | 'blur') {
3728
// TODO: Check if this element focus patching is still needed for local testing,
3829
// where browser is not necessarily focused.
3930
export function patchElementFocus(element: HTMLElement) {
40-
element.focus = () => simulateFocusSequence(element, 'focus');
41-
element.blur = () => simulateFocusSequence(element, 'blur');
31+
element.focus = () => dispatchFakeEvent(element, 'focus');
32+
element.blur = () => dispatchFakeEvent(element, 'blur');
4233
}
4334

4435
/** @docs-private */

0 commit comments

Comments
 (0)