-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Trigger correct events #8963
Trigger correct events #8963
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #8963 +/- ##
==========================================
+ Coverage 74.24% 74.39% +0.14%
==========================================
Files 1332 1352 +20
Lines 40817 41767 +950
Branches 7634 7807 +173
==========================================
+ Hits 30306 31071 +765
- Misses 10511 10696 +185 ☔ View full report in Codecov by Sentry. |
Playwright test resultsDetails Open report ↗︎ Flaky testsedgeSetup › setup/unaffiliated.setup.ts › authenticate with unaffiliated user Skipped testschrome › tests/regressions/doNotCloseSidebarOnPageEditorSave.spec.ts › #8104: Do not automatically close the sidebar when saving in the Page Editor |
@@ -71,8 +72,7 @@ class CustomEventEffect extends EffectABC { | |||
}: BrickArgs<{ eventName: string; data?: JsonObject }>, | |||
{ root = document }: BrickOptions, | |||
): Promise<void> { | |||
const event = new CustomEvent(eventName, { detail: data, bubbles: true }); | |||
root.dispatchEvent(event); | |||
root.dispatchEvent(properEvent(eventName, { detail: data, bubbles: true })); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Technically this brick calls for a "custom event", but this doesn't necessarily mean that prefer CustomEvent('click')
over MouseEvent('click')
@@ -82,16 +83,7 @@ export class ElementEvent extends EffectABC { | |||
// NOTE: the event is not "trusted" as being a user action | |||
// https://developer.mozilla.org/en-US/docs/Web/API/Event/isTrusted | |||
for (const element of $elements) { | |||
if (event === "click") { | |||
if (element instanceof Document) { | |||
logger.warn("Cannot call 'click' on document"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was only a limit of x.click()
, but document.dispatchEvent(new MouseEvent('click'))
works
@@ -132,6 +132,6 @@ export async function setFieldValue( | |||
} | |||
|
|||
// Browsers normally fire this on `blur` if it's a text field, otherwise immediately | |||
field.dispatchEvent(new KeyboardEvent("change", { bubbles: true })); | |||
field.dispatchEvent(new Event("change", { bubbles: true })); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was a bug
No loom links were found in the first post. Please add one there if you'd like to it to appear on Slack. Do not edit this comment manually. |
What does this PR do?
Discussion
I published a dedicated module independently and thought you might find it useful:
Feel free to merge or close the PR
Checklist