-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add option to clear content of input
- Loading branch information
1 parent
5df5c63
commit a1ab773
Showing
6 changed files
with
227 additions
and
47 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
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { buildWaiter } from '@ember/test-waiters'; | ||
const waiter = buildWaiter('@frontile/forms:triggerFormInputEvent)'); | ||
|
||
function triggerFormInputEvent(element?: HTMLElement | null): void { | ||
if (!element) return; | ||
const waiterToken = waiter.beginAsync(); | ||
|
||
requestAnimationFrame(() => { | ||
let parent = element.parentElement; | ||
while (parent) { | ||
if (parent.tagName === 'FORM') { | ||
(parent as HTMLFormElement).dispatchEvent( | ||
new Event('input', { bubbles: true }) | ||
); | ||
break; | ||
} | ||
parent = parent.parentElement; | ||
} | ||
|
||
waiter.endAsync(waiterToken); | ||
}); | ||
} | ||
|
||
export { triggerFormInputEvent }; |
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
Oops, something went wrong.