Skip to content

[ENG-1416] Fix 'create node modal' focus on input box on load#723

Open
trangdoan982 wants to merge 6 commits intomainfrom
cursor/ENG-1316-node-selection-focus-f930
Open

[ENG-1416] Fix 'create node modal' focus on input box on load#723
trangdoan982 wants to merge 6 commits intomainfrom
cursor/ENG-1316-node-selection-focus-f930

Conversation

@trangdoan982
Copy link
Collaborator

@trangdoan982 trangdoan982 commented Jan 23, 2026

https://www.loom.com/share/a092cd458bef479daefce722473e0f0f

Fixes focus jumping to the node type dropdown after selecting a node in ModifyNodeDialog.

This ensures the content input field remains focused, both on dialog open and after selection, for a smoother keyboard-first workflow.


Open in Cursor Open in Web


Open with Devin

UPDATE from @mdroidian : PR title and linear task linked changed. ENG-1416 is the correct task. ENG-1316 is a different issue.

…Enter selection

- Add autoFocus to content input field to focus on dialog open
- Refocus input after selection to maintain keyboard workflow
- Prevents focus from jumping to Node Type dropdown unexpectedly

Fixes ENG-1316

Co-authored-by: doantranghp2000 <doantranghp2000@gmail.com>
@cursor
Copy link

cursor bot commented Jan 23, 2026

Cursor Agent can help with this pull request. Just @cursor in comments and I'll start working on changes in this branch.
Learn more about Cursor Agents

@linear
Copy link

linear bot commented Jan 23, 2026

@supabase
Copy link

supabase bot commented Jan 23, 2026

This pull request has been ignored for the connected project zytfjzqyijgagqxrzbmz because there are no changes detected in packages/database/supabase directory. You can change this behaviour in Project Integrations Settings ↗︎.


Preview Branches by Supabase.
Learn more about Supabase Branching ↗︎.

@trangdoan982 trangdoan982 changed the title Node selection focus [ENG-1316] Node selection focus Jan 25, 2026
@trangdoan982 trangdoan982 marked this pull request as ready for review February 2, 2026 15:21
Copy link
Contributor

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 3 additional flags.

Open in Devin Review

Copy link
Contributor

@mdroidian mdroidian left a comment

Choose a reason for hiding this comment

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

This implementation introduces multiple competing focus mechanisms (Dialog focus + two useEffects + component splitting). That’s fragile because re-renders, portal mount timing, and transition/animation frames can cause focus to bounce or re-trigger.

I’d like us to:

  1. Use Blueprint-native focus first: ensure the intended input has autoFocus, and confirm the Dialog’s focus behavior is configured correctly (enforceFocus etc.).
  2. If we still need JS, keep it to one fallback effect scoped to isOpen that runs once per open (e.g., if (isOpen && !hasFocusedRef.current) focus();). No second component solely for focus.

Worth asking yourself: was this present in the prior modal? If not, identify what changed and why Blueprint’s default focus path no longer works. Also check other dialogs in this repo that have this problem and look for an established pattern.

Copy link
Contributor

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

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

Devin Review found 1 new potential issue.

View 3 additional findings in Devin Review.

Open in Devin Review

Copy link
Contributor

@mdroidian mdroidian left a comment

Choose a reason for hiding this comment

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

https://www.loom.com/share/37020a3f127747e185a54449008fb093

diff --git a/apps/roam/src/components/FuzzySelectInput.tsx b/apps/roam/src/components/FuzzySelectInput.tsx
index 3d8a6629..efea2fa9 100644
--- a/apps/roam/src/components/FuzzySelectInput.tsx
+++ b/apps/roam/src/components/FuzzySelectInput.tsx
@@ -200,7 +200,6 @@ const FuzzySelectInput = <T extends Result = Result>({
         <InputGroup
           fill
           className="w-full"
-          disabled={disabled}
           value={query}
           onChange={(e) => setQuery(e.target.value)}
           onKeyDown={handleKeyDown}
diff --git a/apps/roam/src/components/ModifyNodeDialog.tsx b/apps/roam/src/components/ModifyNodeDialog.tsx
index d949717e..4c04e080 100644
--- a/apps/roam/src/components/ModifyNodeDialog.tsx
+++ b/apps/roam/src/components/ModifyNodeDialog.tsx
@@ -539,6 +539,7 @@ const ModifyNodeDialog = ({
               disabled={loading}
               mode={mode}
               initialUid={content.uid}
+              autoFocus
             />
           </div>
 
@@ -555,6 +556,7 @@ const ModifyNodeDialog = ({
                 mode={"create"}
                 initialUid={referencedNodeValue.uid}
                 initialIsLocked={isReferencedNodeLocked}
+                autoFocus={false}
               />
             </div>
           )}

@mdroidian mdroidian changed the title [ENG-1316] Node selection focus [ENG-1416] Fix 'create node modal' focus on input box on load Feb 11, 2026
@mdroidian
Copy link
Contributor

It looks like the PR 723 was linked to the wrong linear issue. 723 is fixing FEE-695 which did not yet have an ENG ticket. I went ahead and created the ENG ticket, changed the title of this PR, and updated the linear links.

}
}, [activeIndex, isOpen]);

useEffect(() => {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

on Canvas in "create" mode the autofocus doesn't get applied.

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.

3 participants