-
Notifications
You must be signed in to change notification settings - Fork 6.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(select): tab opening multiple select and space scrolling page (#4210
) * fix(select): tab opening multiple select and space scrolling page * Fixes pressing tab (or any other key, except arrows) opening `md-select` in `multiple` mode. * Fixes the page getting scrolled down when opening a select by pressing space. * Adds missing test coverage for opening a multiple select with the arrow keys. * fix: defaultPrevented not working on IE * chore: cleaner dispatching of fake events
- Loading branch information
Showing
4 changed files
with
97 additions
and
35 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,20 +1,22 @@ | ||
import { | ||
createFakeEvent, | ||
createKeyboardEvent, | ||
createMouseEvent | ||
} from './event-objects'; | ||
import {createFakeEvent, createKeyboardEvent, createMouseEvent} from './event-objects'; | ||
|
||
/** Utility to dispatch any event on a Node. */ | ||
export function dispatchEvent(node: Node | Window, event: Event): Event { | ||
node.dispatchEvent(event); | ||
return event; | ||
} | ||
|
||
/** Shorthand to dispatch a fake event on a specified node. */ | ||
export function dispatchFakeEvent(node: Node | Window, type: string) { | ||
node.dispatchEvent(createFakeEvent(type)); | ||
export function dispatchFakeEvent(node: Node | Window, type: string): Event { | ||
return dispatchEvent(node, createFakeEvent(type)); | ||
} | ||
|
||
/** Shorthand to dispatch a keyboard event with a specified key code. */ | ||
export function dispatchKeyboardEvent(node: Node, type: string, keyCode: number) { | ||
node.dispatchEvent(createKeyboardEvent(type, keyCode)); | ||
export function dispatchKeyboardEvent(node: Node, type: string, keyCode: number): KeyboardEvent { | ||
return dispatchEvent(node, createKeyboardEvent(type, keyCode)) as KeyboardEvent; | ||
} | ||
|
||
/** Shorthand to dispatch a mouse event on the specified coordinates. */ | ||
export function dispatchMouseEvent(node: Node, type: string, x = 0, y = 0) { | ||
node.dispatchEvent(createMouseEvent(type, x, y)); | ||
export function dispatchMouseEvent(node: Node, type: string, x = 0, y = 0): MouseEvent { | ||
return dispatchEvent(node, createMouseEvent(type, x, y)) as MouseEvent; | ||
} |
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