Skip to content

fix: unfocus UI inputs on viewport click, refuse duplicate id in ID input#79

Merged
vincentfretin merged 2 commits into
devfrom
fix-stale-id-input-commit-dev
Jul 13, 2026
Merged

fix: unfocus UI inputs on viewport click, refuse duplicate id in ID input#79
vincentfretin merged 2 commits into
devfrom
fix-stale-id-input-commit-dev

Conversation

@vincentfretin

@vincentfretin vincentfretin commented Jul 13, 2026

Copy link
Copy Markdown
Member

Two improvements to the panel/viewport interaction:

Unfocus UI inputs when clicking the viewport

raycaster.js called event.preventDefault() on every viewport mousedown, which cancels the browser's default focus transfer — so clicking the viewport never unfocused the currently focused panel input.

  • Only preventDefault() non-left buttons now (still needed so middle-click zoom doesn't trigger the browser's autoscroll). Left-click performs the native focus transfer, so a focused input blurs — and commits its pending edit — before the selection changes.
  • user-select: none added on the canvas, since preventDefault() was incidentally blocking drag-started text selection (drag-orbiting could otherwise select panel text).

Refuse duplicate ids in the ID input

Typing an id that already belongs to another element was silently committed, producing a duplicate id in the document, which breaks entity lookups done with getElementById/querySelector (selector-type component properties, links between entities, …).

changeId now refuses such a value: a message is shown below the input and the input is remounted so it displays the entity's current id again.

The id "aBox" is already used by another element, the previous id was restored.

Dead CSS cleanup

The .aframe-inspector-opened a-scene .a-canvas and .a-canvas.state-dragging rules in index.styl are nested under #aframeInspector, and the canvas is not a descendant of it, so they never matched (nothing in src adds the state-dragging class anyway). Removed; the new user-select rule lives under body.aframe-inspector-opened, which does match.

Tested

On the examples page with headless Chromium: viewport left-click blurs a focused id input; typing an existing id is refused with the message shown, and the message clears on entity switch; canvas user-select is none; middle/right-click still preventDefault.

🤖 Generated with Claude Code

…nput

raycaster.js preventDefault'ed every mousedown on the viewport, which
canceled the browser's default focus transfer, so clicking the viewport
never unfocused the currently focused panel input. Only preventDefault
non-left buttons now (still needed so middle-click zoom doesn't trigger
autoscroll) and add user-select none on the canvas to keep drag-orbits
from starting a text selection, which the preventDefault was
incidentally providing.

changeId now refuses an id already used by another element (a duplicate
id breaks entity lookups done with getElementById/querySelector) and
shows a message below the input explaining the previous id was restored.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@vincentfretin
vincentfretin force-pushed the fix-stale-id-input-commit-dev branch from f8dd1f3 to 4998e39 Compare July 13, 2026 07:11
@vincentfretin vincentfretin changed the title fix: id input committing stale value to newly selected entity on blur fix: unfocus UI inputs on viewport click, refuse duplicate id in ID input Jul 13, 2026
The .aframe-inspector-opened a-scene .a-canvas and
.a-canvas.state-dragging rules are nested under #aframeInspector, and
the canvas is not a descendant of it, so they never matched. Nothing in
src adds the state-dragging class anyway.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@vincentfretin
vincentfretin force-pushed the fix-stale-id-input-commit-dev branch from 824d8ae to 3bfd4ff Compare July 13, 2026 07:18
@vincentfretin
vincentfretin merged commit 8b7307b into dev Jul 13, 2026
1 check passed
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.

1 participant