Skip to content

fix: close toolbar dropdowns when clicking in editor area#2170

Closed
gpardhivvarma wants to merge 1 commit intosuperdoc-dev:mainfrom
gpardhivvarma:fix/toolbar-dropdowns-not-closing-on-editor-click
Closed

fix: close toolbar dropdowns when clicking in editor area#2170
gpardhivvarma wants to merge 1 commit intosuperdoc-dev:mainfrom
gpardhivvarma:fix/toolbar-dropdowns-not-closing-on-editor-click

Conversation

@gpardhivvarma
Copy link

@gpardhivvarma gpardhivvarma commented Feb 25, 2026

Summary

Fixes #2169

  • Toolbar dropdowns (font family, font size, table edit, etc.) now close when clicking in the editor area
  • Root cause: EditorInputManager calls preventDefault() on pointerdown in the editor viewport, which suppresses mousedown/click per the Pointer Events spec. Naive UI's NDropdown relies on mousedown for click-outside detection, so it never sees the click.
  • Fix: Add a pointerdown-based click-outside listener in ButtonGroup.vue that closes open dropdowns when clicking outside the toolbar UI surface. pointerdown always fires regardless of preventDefault() calls.

Test plan

  • Open a document
  • Open a toolbar dropdown (font family, font size, etc.)
  • Click in the editor area — dropdown should close
  • Open the dropdown again, click inside the dropdown to select an option — should work normally
  • Open the dropdown again, press Escape — should still close (existing behavior)

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b821d4334b

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@gpardhivvarma gpardhivvarma force-pushed the fix/toolbar-dropdowns-not-closing-on-editor-click branch from b821d43 to e0050df Compare February 25, 2026 12:25
@gpardhivvarma
Copy link
Author

@codex review

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e0050df866

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

EditorInputManager calls preventDefault() on pointerdown in the editor
viewport, which suppresses mousedown/click events per the Pointer Events
spec. Since Naive UI's NDropdown uses mousedown for click-outside
detection, dropdowns remain open when clicking back into the editor.

Add a pointerdown-based click-outside listener in ButtonGroup.vue that
closes open dropdowns when clicking outside the toolbar UI surface.
pointerdown always fires regardless of preventDefault() calls.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@gpardhivvarma gpardhivvarma force-pushed the fix/toolbar-dropdowns-not-closing-on-editor-click branch from e0050df to b0e6bd2 Compare February 25, 2026 13:00
@gpardhivvarma
Copy link
Author

@codex review

@chatgpt-codex-connector
Copy link

Codex Review: Didn't find any major issues. 🚀

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@caio-pizzol
Copy link
Contributor

hey @gpardhivvarma - thanks for the PR and especially the root cause analysis, nailing it down to preventDefault() on pointerdown blocking Naive UI's click-outside detection was great detective work.

closing this one in favor of #2174 (since both PRs solve the same problem and there's significant overlap), but really appreciate you jumping in on this.

if you're interested in contributing more, feel free to check out our open issues especially the ones with good first issue label

@gpardhivvarma
Copy link
Author

Thank you . I will surely check out some good first issues. I am fairly new to open source , just started with this because it's an issue we are facing in our org using super doc.

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.

Table Edit feature not closing when clicking on the editor | Happening with every dropdown in the toolbar

2 participants