Skip to content

Commit

Permalink
fix(whatInput): Type event listeners (microsoft#20024)
Browse files Browse the repository at this point in the history
* fix(whatInput): Type event listeners

Adds the `WhatInputEvents` to type event listeners with the events that
can be used by what-input

* changelog entry
  • Loading branch information
ling1726 authored and Marion Le Pontois committed Jan 17, 2022
1 parent 217947f commit 9d4e9b8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions packages/fluentui/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm

### Fixes
- `Popup` should not dismiss when its iframe content is focused @ling1726 ([#19955](https://github.com/microsoft/fluentui/pull/19955))
- `whatInput` Add typings to what input event listeners @ling1726 ([#20024](https://github.com/microsoft/fluentui/pull/20024))


<!--------------------------------[ v0.59.0 ]------------------------------- -->
Expand Down
6 changes: 4 additions & 2 deletions packages/fluentui/react-northstar/src/utils/whatInput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ const setUp = () => {
doUpdate(window.document);
};

type WhatInputEvents = MouseEvent | TouchEvent | KeyboardEvent;

/*
* events
*/
Expand Down Expand Up @@ -107,7 +109,7 @@ const addListeners = (eventTarget: Window) => {
};

// checks conditions before updating new input
const setInput = event => {
const setInput = (event: WhatInputEvents) => {
// only execute if the event buffer timer isn't running
if (!isBuffering) {
const eventKey = event.which;
Expand All @@ -133,7 +135,7 @@ const doUpdate = (target: Document) => {
};

// buffers events that frequently also fire mouse events
const eventBuffer = event => {
const eventBuffer = (event: WhatInputEvents) => {
// set the current input
setInput(event);

Expand Down

0 comments on commit 9d4e9b8

Please sign in to comment.