Skip to content

Commit

Permalink
Merge pull request #26198 from software-mansion-labs/ts-migration/dom…
Browse files Browse the repository at this point in the history
…-utils-lib
  • Loading branch information
cead22 authored Sep 19, 2023
2 parents c249238 + 3efa284 commit f700942
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 22 deletions.
12 changes: 0 additions & 12 deletions src/libs/DomUtils/index.js

This file was deleted.

10 changes: 0 additions & 10 deletions src/libs/DomUtils/index.native.js

This file was deleted.

10 changes: 10 additions & 0 deletions src/libs/DomUtils/index.native.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import {BlurActiveElement, GetActiveElement} from './types';

const blurActiveElement: BlurActiveElement = () => {};

const getActiveElement: GetActiveElement = () => null;

export default {
blurActiveElement,
getActiveElement,
};
18 changes: 18 additions & 0 deletions src/libs/DomUtils/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import {BlurActiveElement, GetActiveElement} from './types';

const blurActiveElement: BlurActiveElement = () => {
const activeElement = document.activeElement as HTMLElement;

if (!activeElement?.blur) {
return;
}

activeElement.blur();
};

const getActiveElement: GetActiveElement = () => document.activeElement;

export default {
blurActiveElement,
getActiveElement,
};
4 changes: 4 additions & 0 deletions src/libs/DomUtils/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
type BlurActiveElement = () => void;
type GetActiveElement = () => Element | null;

export type {BlurActiveElement, GetActiveElement};

0 comments on commit f700942

Please sign in to comment.