Skip to content

Conversation

mtorromeo
Copy link
Contributor

@mtorromeo mtorromeo commented Nov 25, 2023

This pr fixes some imprecise Event definitions and adds some that were missing.

The list was compiled by consulting the list of events documented on MDN that are fired by Element or a subclass and where the event is not experimental.

Personally, I was impacted more often by the wrong onInput and onSubmit definitions.

Some other notable changes are the onClick event being changed to PointerEvent (which extends MouseEvent, so I don't see an issue here) and onScroll, being the only downgrade, which was not documented as an UiEvent on MDN, and I am not sure why it was defined as such here.

Summary by CodeRabbit

  • New Features

    • Added broader event handler support: cancel, formdata, fullscreen change/error, popover beforetoggle/toggle, animation cancel, security policy violation, transition cancel/run, pointer capture events.
    • Restored click/contextmenu/auxclick as pointer events.
  • Bug Fixes

    • Improved input handling: onInput now receives richer input event data.
  • Refactor

    • Updated Details element event handling (onToggle removed from Details attributes).

mtorromeo added a commit to mtorromeo/vue-patternfly that referenced this pull request Nov 25, 2023
nazarii828 added a commit to nazarii828/vue-patternfly that referenced this pull request Mar 18, 2024
brendon726 added a commit to brendon726/Vue-patternfly that referenced this pull request Mar 27, 2024
@edison1105 edison1105 added ready to merge The PR is ready to be merged. scope: types labels Sep 24, 2024
@edison1105
Copy link
Member

Thanks for this PR. Could you please resolve the conflicts?

Copy link

coderabbitai bot commented Sep 24, 2025

Walkthrough

Updated JSX event handler typings in packages/runtime-dom/src/jsx.ts: removed DetailsHTMLAttributes.onToggle, added several new event handlers (formdata, fullscreen, popover, animation, security, transition, cancel), changed onInput to InputEvent, and reorganized mouse events under pointer events with additional pointer handlers.

Changes

Cohort / File(s) Change Summary
Runtime DOM JSX typings
packages/runtime-dom/src/jsx.ts
- Removed DetailsHTMLAttributes.onToggle.
- Added DialogHTMLAttributes.onCancel and InputHTMLAttributes.onCancel.
- Added onFormdata: FormDataEvent.
- Added onFullscreenchange: Event, onFullscreenerror: Event.
- Added popover events: onBeforetoggle: ToggleEvent, onToggle: ToggleEvent.
- Added onAnimationcancel: AnimationEvent.
- Added onSecuritypolicyviolation: SecurityPolicyViolationEvent.
- Added transition events: onTransitioncancel, onTransitionrun (TransitionEvent).
- Changed onInput type from EventInputEvent.
- Reclassified mouse handlers to pointer events and added onAuxclick, onClick, onContextmenu, onGotpointercapture, onLostpointercapture as PointerEvent.
- Reorganized Events interface/groupings accordingly.

Sequence Diagram(s)

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Poem

A rabbit hops through typings bright,
I nudge events until they’re right.
Pointers, formdata, fullscreen cheer—
Small changes, crisp as carrot near.
Hooray for types that now take flight! 🥕

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
Title Check ✅ Passed The title "chore(types): more precise types for Events and added missing definitions" accurately and concisely captures the primary intent of the changeset — refining event typings and adding missing event definitions — and aligns with the PR objectives and file-level summaries. It uses a conventional-commit style and is specific enough that a teammate scanning the history understands the main change. The title is neither vague nor unrelated to the changes made.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@mtorromeo
Copy link
Contributor Author

@edison1105 done, thanks

@mtorromeo
Copy link
Contributor Author

mtorromeo commented Sep 24, 2025

I just noticed that the onToggle event that has since been added to DetailsHTMLAttributes but MDN defines it as a HTMLElement event. It should probably be removed from DetailsHTMLAttributes.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
packages/runtime-dom/src/jsx.ts (1)

1327-1331: Form-event typings look good; move onCancel comment to “dialog events” and check TS baseline

  • onInput: InputEvent and onFormdata: FormDataEvent are correct.
  • onCancel is a dialog event (HTMLDialogElement); keeping it in the global Events map is fine, but move the comment header from “form events” to “dialog events” for clarity.
  • lib.dom availability: FormDataEvent and SubmitEvent added in TypeScript 4.4; InputEvent changes landed around Dec 2021 and appear in TypeScript 4.5+. Ensure project minimum TypeScript/lib.dom >=4.5 if relying on InputEvent (>=4.4 for FormDataEvent/SubmitEvent).
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b555f02 and 55e6481.

📒 Files selected for processing (1)
  • packages/runtime-dom/src/jsx.ts (3 hunks)
🔇 Additional comments (5)
packages/runtime-dom/src/jsx.ts (5)

1336-1339: Add fullscreen events: LGTM.

onFullscreenchange/onFullscreenerror as Event align with MDN.


1419-1419: Add onAnimationcancel: LGTM.

Correct type and name.


1424-1426: Add Security Policy Violation event: LGTM.

onSecuritypolicyviolation: SecurityPolicyViolationEvent matches MDN.


1428-1428: Add transitioncancel/run: LGTM.

Both are valid TransitionEvent entries.

Also applies to: 1431-1431


1411-1414: Popover events: ToggleEvent requires TypeScript 5.5+ — confirm project TS or add fallback

ToggleEvent was added to lib.dom in TypeScript 5.5 (seen in TS 5.5.3). If our minimum TS < 5.5, widen the props to Event or add a local conditional alias at packages/runtime-dom/src/jsx.ts (lines 1411–1414).

Copy link

github-actions bot commented Sep 24, 2025

Size Report

Bundles

File Size Gzip Brotli
runtime-dom.global.prod.js 102 kB 38.6 kB 34.7 kB
vue.global.prod.js 160 kB 58.7 kB 52.3 kB

Usages

Name Size Gzip Brotli
createApp (CAPI only) 46.7 kB 18.3 kB 16.7 kB
createApp 54.7 kB 21.3 kB 19.5 kB
createSSRApp 58.9 kB 23 kB 21 kB
defineCustomElement 60 kB 23 kB 20.9 kB
overall 68.8 kB 26.5 kB 24.2 kB

Copy link

pkg-pr-new bot commented Sep 24, 2025

Open in StackBlitz

@vue/compiler-core

npm i https://pkg.pr.new/@vue/compiler-core@9675

@vue/compiler-dom

npm i https://pkg.pr.new/@vue/compiler-dom@9675

@vue/compiler-sfc

npm i https://pkg.pr.new/@vue/compiler-sfc@9675

@vue/compiler-ssr

npm i https://pkg.pr.new/@vue/compiler-ssr@9675

@vue/reactivity

npm i https://pkg.pr.new/@vue/reactivity@9675

@vue/runtime-core

npm i https://pkg.pr.new/@vue/runtime-core@9675

@vue/runtime-dom

npm i https://pkg.pr.new/@vue/runtime-dom@9675

@vue/server-renderer

npm i https://pkg.pr.new/@vue/server-renderer@9675

@vue/shared

npm i https://pkg.pr.new/@vue/shared@9675

vue

npm i https://pkg.pr.new/vue@9675

@vue/compat

npm i https://pkg.pr.new/@vue/compat@9675

commit: 23ccfeb

@mtorromeo
Copy link
Contributor Author

Moved onCancel to InputHTMLAttributes and DialogHTMLAttributes

@edison1105 edison1105 changed the title fix(types): more precise types for Events and added missing definitions chore(types): more precise types for Events and added missing definitions Sep 24, 2025
@edison1105
Copy link
Member

/ecosystem-ci run

@vue-bot
Copy link
Contributor

vue-bot commented Sep 24, 2025

📝 Ran ecosystem CI: Open

suite result latest scheduled
language-tools success success
pinia success success
primevue success success
quasar success success
nuxt success success
test-utils success success
vant failure success
vue-i18n success success
vitepress success success
radix-vue success success
vite-plugin-vue success success
router success success
vuetify failure failure
vue-macros failure success
vueuse success success
vue-simple-compiler success success

@edison1105 edison1105 merged commit 8bb8fb2 into vuejs:main Sep 24, 2025
14 checks passed
@TheSeg
Copy link

TheSeg commented Sep 25, 2025

I just want to say thank you for updating the typings!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready to merge The PR is ready to be merged. scope: types
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants