Skip to content

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

Merged
dmarcos merged 2 commits into
aframevr:masterfrom
vincentfretin:fix-unfocus-viewport-click-master
Jul 14, 2026
Merged

fix: unfocus UI inputs on viewport click, refuse duplicate id in ID input#860
dmarcos merged 2 commits into
aframevr:masterfrom
vincentfretin:fix-unfocus-viewport-click-master

Conversation

@vincentfretin

@vincentfretin vincentfretin commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

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.

Capture d’écran du 2026-07-13 09-31-29 Capture d’écran du 2026-07-13 09-31-36

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; a valid rename still works and emits entityidchange; canvas user-select is none; middle/right-click still preventDefault.

Same change on the aframe-editor fork: c-frame#79

🤖 Generated with Claude Code

vincentfretin and others added 2 commits July 13, 2026 09:27
…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>
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>
@dmarcos
dmarcos merged commit 8d87d3e into aframevr:master Jul 14, 2026
1 check passed
@vincentfretin
vincentfretin deleted the fix-unfocus-viewport-click-master branch July 14, 2026 07:20
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