Skip to content

fix: Create an ElementInput in Application - #353

Open
willeastcott wants to merge 1 commit into
mainfrom
fix/react-element-input
Open

willeastcott wants to merge 1 commit into
mainfrom
fix/react-element-input

Conversation

@willeastcott

Copy link
Copy Markdown
Contributor

<Application> creates the mouse and touch devices but no ElementInput, the object that turns input into events on element components. Without it, <Element useInput> receives no events, buttons added to elements never react, and scroll views and scrollbars can't be dragged. The engine only reports it through a debug-build warning, so in a production build the UI is silently inert.

This creates one when the application is created. It is created before the mouse and touch devices, so its window listeners run first: calling stopPropagation() in a UI event handler then also keeps the event from app.mouse and app.touch (for example, app.mouse.wasPressed() stays false for a click on a button), which is the order the Editor's launcher uses.

Checked in Chrome with engine 2.22.4: with no other setup, a button's click, an element's click and mousedown fire, and stopPropagation() on mousedown keeps app.mouse.wasPressed() false, in StrictMode too. <Entity onClick> picking still works alongside it.

The test setup's mock Application now passes the elementInput option through, so a new test can check that the application has one and that it is bound to the app. A changeset is included (patch).

Found while rewriting the User Interface chapter of the User Manual; its React examples would otherwise need a wrapper component that creates the ElementInput and re-attaches the mouse and touch devices.

🤖 Generated with Claude Code

<Application> created the mouse and touch devices but no ElementInput, the
object that turns input into events on element components. Without it,
elements with useInput received no events, buttons never reacted, and
scroll views and scrollbars could not be dragged. The debug engine only
warns about it.

Create one when the application is created, before the mouse and touch
devices, so its listeners run first and stopPropagation() in a UI event
handler also keeps the event from app.mouse and app.touch.

The test setup's mock Application now passes the element input through,
so the new test can check it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@changeset-bot

changeset-bot Bot commented Sep 24, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 503f52e

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@playcanvas/react Patch
@playcanvas/blocks Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@pkg-pr-new

pkg-pr-new Bot commented Sep 24, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@playcanvas/blocks@353
npm i https://pkg.pr.new/@playcanvas/react@353

commit: 503f52e

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