Skip to content

fix(core): preserve nested control focus on node click#2414

Open
puneetdixit200 wants to merge 1 commit into
didi:masterfrom
puneetdixit200:fix-node-nested-control-focus
Open

fix(core): preserve nested control focus on node click#2414
puneetdixit200 wants to merge 1 commit into
didi:masterfrom
puneetdixit200:fix-node-nested-control-focus

Conversation

@puneetdixit200

Copy link
Copy Markdown

Description

This change prevents node click handling from forcing focus back to the node wrapper when the original click target is a nested form/editor control.

The node still restores wrapper focus for ordinary node clicks, preserving the copy/paste focus behavior that the existing requestAnimationFrame(...focus()) path was added for.

Motivation and Context

Fixes #2406.

Custom nodes can embed controls such as input, select, textarea, buttons, or contenteditable editors. The current handleClick implementation schedules currentTarget.focus() after every node click, so clicking one of those embedded controls can immediately move focus away from the control.

This patch skips wrapper focus only when the click target is inside one of those nested controls and adds a regression test for that path.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Enhancement (changes that improvement of current feature or performance)
  • Refactoring (changes that neither fixes a bug nor adds a feature)
  • Test Case (changes that add missing tests or correct existing tests)
  • Code style optimization (changes that do not affect the meaning of the code)
  • Docs (changes that add or update documentation)
  • Chore (changes that do not modify src or test files)

Self Check before Merge

  • My code follows the code style of this project
  • My change requires a change to the documentation
  • I have updated the documentation accordingly
  • I have read the CONTRIBUTING document
  • I have added tests to cover my changes.
  • All new and existing tests passed.

Verification:

  • pnpm test -- packages/core/__tests__/bugs/2406-spec.test.ts --runInBand
  • pnpm exec eslint packages/core/src/view/node/BaseNode.tsx packages/core/__tests__/bugs/2406-spec.test.ts
  • pnpm --filter @logicflow/core run build:esm
  • git diff --check

@changeset-bot

changeset-bot Bot commented Jun 5, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: ffbd054

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

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.

【Bug】节点 handleClick 强制 el.focus() 导致嵌套表单/输入框失焦,影响交互体验

1 participant