Skip to content

fix(editor): pasting into database multiselect input auto adds a new tag #12693

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

golok727
Copy link
Contributor

@golok727 golok727 commented Jun 3, 2025

close: #12442

Summary by CodeRabbit

  • Bug Fixes
    • Improved paste handling to prevent interference with native paste behavior in input and textarea fields within table views.

@golok727 golok727 requested a review from a team as a code owner June 3, 2025 16:05
@graphite-app graphite-app bot requested a review from a team June 3, 2025 16:05
Copy link
Contributor

coderabbitai bot commented Jun 3, 2025

Walkthrough

The _onPaste method in the TableClipboardController class was updated in two files to check if the focused element is an <input> or <textarea>. If so, the method exits early, preventing custom paste logic from running and allowing native paste behavior in those fields.

Changes

File(s) Change Summary
.../table/pc-virtual/controller/clipboard.ts
.../table/pc/controller/clipboard.ts
Added early return in _onPaste to skip custom handling when focus is on <input> or <textarea>.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Browser
    participant TableClipboardController

    User->>Browser: Paste event
    Browser->>TableClipboardController: _onPaste(event)
    TableClipboardController->>Browser: Check document.activeElement
    alt Focus is input or textarea
        TableClipboardController-->>Browser: Return true (skip custom paste logic)
    else Focus is elsewhere
        TableClipboardController->>TableClipboardController: Process clipboard data
        TableClipboardController->>Browser: Paste into table
    end
Loading

Assessment against linked issues

Objective Addressed Explanation
Prevent custom paste logic from interfering with native paste in multi-select/input fields (#12442)

Poem

In the table fields where data flows,
The rabbit hops—now everyone knows!
Paste in inputs? Native rules apply,
No more double tags to mystify.
With careful checks and nimble code,
The clipboard’s path is rightly bestowed!
🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 44e1eb5 and 8b3f601.

📒 Files selected for processing (2)
  • blocksuite/affine/data-view/src/view-presets/table/pc-virtual/controller/clipboard.ts (1 hunks)
  • blocksuite/affine/data-view/src/view-presets/table/pc/controller/clipboard.ts (1 hunks)
🔇 Additional comments (2)
blocksuite/affine/data-view/src/view-presets/table/pc-virtual/controller/clipboard.ts (1)

82-88: Excellent fix for the multiselect input paste issue!

This early exit condition effectively prevents the custom table paste logic from interfering with native paste behavior in input and textarea elements. The implementation correctly:

  • Safely handles the case where document.activeElement might be null
  • Uses proper tag name comparison (DOM tagName returns uppercase)
  • Returns early to preserve native paste functionality in form elements

This directly addresses the reported issue where pasting into database multiselect inputs would auto-add new tags.

blocksuite/affine/data-view/src/view-presets/table/pc/controller/clipboard.ts (1)

81-87: Great consistency with the virtual table implementation!

This implementation is identical to the fix in the virtual table controller, ensuring consistent behavior across both table view types. The early exit logic properly prevents custom paste handling when users are focused on input or textarea elements, allowing native paste behavior to work as expected.

The consistent application of this fix across both implementations ensures users will have the same experience regardless of which table view they're using.

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@graphite-app graphite-app bot requested a review from a team June 3, 2025 16:05
Copy link
Contributor

graphite-app bot commented Jun 3, 2025

How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • merge - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

@golok727
Copy link
Contributor Author

golok727 commented Jun 5, 2025

@zzj3720 PTAL

Copy link

codecov bot commented Jun 6, 2025

Codecov Report

Attention: Patch coverage is 50.00000% with 4 lines in your changes missing coverage. Please review.

Project coverage is 55.63%. Comparing base (72e66ac) to head (d20b312).
Report is 5 commits behind head on canary.

Files with missing lines Patch % Lines
...w-presets/table/pc-virtual/controller/clipboard.ts 50.00% 2 Missing ⚠️
.../src/view-presets/table/pc/controller/clipboard.ts 50.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           canary   #12693      +/-   ##
==========================================
- Coverage   55.94%   55.63%   -0.32%     
==========================================
  Files        2653     2653              
  Lines      125303   125311       +8     
  Branches    19898    19836      -62     
==========================================
- Hits        70103    69713     -390     
- Misses      52858    53292     +434     
+ Partials     2342     2306      -36     
Flag Coverage Δ
server-test 79.03% <ø> (-0.73%) ⬇️
unittest 31.59% <0.00%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Saul-Mirone Saul-Mirone merged commit f69a98e into toeverything:canary Jun 9, 2025
108 of 111 checks passed
@golok727 golok727 deleted the fix/table_multi_select_paste branch June 9, 2025 08:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

[Bug]: Pasting into multi-select column of table
3 participants