Skip to content
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

Merged
merged 6 commits into from
Aug 2, 2024
Merged

Trigger correct events #8963

merged 6 commits into from
Aug 2, 2024

Conversation

fregante
Copy link
Contributor

@fregante fregante commented Aug 1, 2024

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

  • This PR introduces a new library: double check it's MIT/Apache2/permissively licensed

Copy link

codecov bot commented Aug 1, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 74.39%. Comparing base (8318d74) to head (4bbec0a).
Report is 152 commits behind head on main.

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.
📢 Have feedback on the report? Share it here.

Copy link

github-actions bot commented Aug 1, 2024

Playwright test results

passed  115 passed
flaky  5 flaky
skipped  6 skipped

Details

report  Open report ↗︎
stats  126 tests across 42 suites
duration  12 minutes, 17 seconds
commit  4bbec0a
info  For more information on how to debug and view this report, see our readme

Flaky tests

edgeSetup › setup/unaffiliated.setup.ts › authenticate with unaffiliated user
chrome › tests/pageEditor/addStarterBrick.spec.ts › Add starter brick to mod
edge › tests/pageEditor/addStarterBrick.spec.ts › Add starter brick to mod
edge › tests/pageEditor/copyMod.spec.ts › run a copied mod with a built-in integration
edge › tests/pageEditor/modEditorPane.spec.ts › mod editor pane behavior

Skipped tests

chrome › tests/regressions/doNotCloseSidebarOnPageEditorSave.spec.ts › #8104: Do not automatically close the sidebar when saving in the Page Editor
edge › tests/regressions/doNotCloseSidebarOnPageEditorSave.spec.ts › #8104: Do not automatically close the sidebar when saving in the Page Editor
chrome › tests/runtime/googleSheetsIntegration.spec.ts › can activate a google spreadsheet mod with config options
edge › tests/runtime/googleSheetsIntegration.spec.ts › can activate a google spreadsheet mod with config options
chrome › tests/runtime/insertAtCursor.spec.ts › Insert at Cursor › 8154: can insert at cursor after opening sidebar from selection menu
edge › tests/runtime/insertAtCursor.spec.ts › Insert at Cursor › 8154: can insert at cursor after opening sidebar from selection menu

@@ -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 }));
Copy link
Contributor Author

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");
Copy link
Contributor Author

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 }));
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was a bug

@fungairino fungairino enabled auto-merge (squash) August 2, 2024 16:06
Copy link

github-actions bot commented Aug 2, 2024

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.

@fungairino fungairino merged commit 5bb2c66 into main Aug 2, 2024
26 checks passed
@fungairino fungairino deleted the proper-event branch August 2, 2024 16:22
@grahamlangford grahamlangford added this to the 2.0.7 milestone Aug 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DOM event simulation improvements
4 participants