Skip to content

docs: restructure TypeScript event handling and JSX directive sections#1533

Open
harshagarwalnyu wants to merge 2 commits into
solidjs:mainfrom
harshagarwalnyu:docs/restructure-typescript-event-handling
Open

docs: restructure TypeScript event handling and JSX directive sections#1533
harshagarwalnyu wants to merge 2 commits into
solidjs:mainfrom
harshagarwalnyu:docs/restructure-typescript-event-handling

Conversation

@harshagarwalnyu
Copy link
Copy Markdown
Contributor

The TypeScript page had on:___ event handling docs split into two disconnected places, and some headings buried too deep to appear in the page outline. This PR fixes all the issues raised in #569.

What changed:

Moved on: docs into the Event handling section. The "Custom event handlers" content was living under "Advanced JSX attributes and directives" even though it's just another way to handle events. It's now an on: directive subsection directly under Event handling, where readers would expect to find it.

Converted the native events callout to a real subsection. The guidance about extending CustomEvents with HTMLElementEventMap was buried inside a :::note callout. It's now a proper "Using native events with on:" subsection, making it easier to discover and link to.

Upgraded heading levels for Forcing properties and Custom directives. Both were at the #### level, which means they didn't show up in the page outline. They're now ### so readers can navigate to them from the outline.

Addresses all four items from #569.

- Move custom/native on: event docs into API types > Event handling
- Add dedicated section for on: directive with subsections for custom
  and native events
- Convert native events callout to a proper subsection
- Promote Forcing properties and Custom directives headings to h3
  so they appear in the page outline

Closes solidjs#569
Copilot AI review requested due to automatic review settings June 1, 2026 04:06
@bolt-new-by-stackblitz
Copy link
Copy Markdown

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@netlify
Copy link
Copy Markdown

netlify Bot commented Jun 1, 2026

Deploy Preview for solid-docs ready!

Name Link
🔨 Latest commit 8a1566e
🔍 Latest deploy log https://app.netlify.com/projects/solid-docs/deploys/6a1d061cc4d78b000866312a
😎 Deploy Preview https://deploy-preview-1533--solid-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Updates the TypeScript documentation to better explain Solid’s on: directive and how to type custom/native events, while removing the older duplicated “Custom event handlers” section.

Changes:

  • Added a dedicated “The on: directive” section with examples for custom events and listener options.
  • Documented how to extend CustomEvents to support native events (all or selected).
  • Reorganized “Advanced JSX attributes and directives” headings by removing the older custom-events subsection and promoting subsequent sections.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +454 to +461
class NameEvent extends CustomEvent {
type: "Name";
detail: { name: string };

constructor(name: string) {
super("Name", { detail: { name } });
}
}
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 8a1566e. Using CustomEvent<{ name: string }> generic now, dropped the field declarations entirely.

Comment on lines +483 to +485
import type { JSX } from "solid-js"

const handler: JSX.EventHandlerWithOptions<HTMLDivElement, Event> = {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 8a1566e. Added semicolon after import, removed the extra space.


##### Using native events with `on:`

By default, using native events like `mousemove` with the `on` prefix — for example, `<div on:mousemove={e => {}} />` — will trigger a TypeScript error.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 8a1566e. Changed to on: prefix throughout that section.

Comment on lines +505 to +509
declare module "solid-js" {
namespace JSX {
interface CustomEvents extends HTMLElementEventMap {}
}
}
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good call. Added a parenthetical note: 'which covers HTML element events -- not Document or Window events'.

- Use CustomEvent<{name: string}> generic instead of field declarations
- Fix semicolon and whitespace in EventHandlerWithOptions example
- Change on prefix to on: prefix for clarity
- Note that HTMLElementEventMap covers HTML element events only
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants