Skip to content

[WIP][lexical-table] Feature: Use custom selection behavior for table cell triple click#7005

Closed
etrepum wants to merge 2 commits into
facebook:mainfrom
etrepum:table-cell-triple-click
Closed

[WIP][lexical-table] Feature: Use custom selection behavior for table cell triple click#7005
etrepum wants to merge 2 commits into
facebook:mainfrom
etrepum:table-cell-triple-click

Conversation

@etrepum

@etrepum etrepum commented Dec 30, 2024

Copy link
Copy Markdown
Collaborator

Description

The native browser triple click over-selects in tables compared to the expectation of selecting the cell. By adding a click handler that looks for detail === 3 we can detect this event and customize the behavior.

TODO:

  • See if it's possible to prevent the native flash of the over-select before it's fixed by this custom handler
  • e2e test

Closes #6973

Test plan

Before

Insert relevant screenshots/recordings/automated-tests

After

Insert relevant screenshots/recordings/automated-tests

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Dec 30, 2024
@vercel

vercel Bot commented Dec 30, 2024

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
lexical ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 21, 2025 7:04pm
lexical-playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 21, 2025 7:04pm

@github-actions

github-actions Bot commented Dec 30, 2024

Copy link
Copy Markdown

size-limit report 📦

Path Size
lexical - cjs 29.07 KB (0%)
lexical - esm 28.86 KB (0%)
@lexical/rich-text - cjs 38.04 KB (0%)
@lexical/rich-text - esm 30.92 KB (0%)
@lexical/plain-text - cjs 36.55 KB (0%)
@lexical/plain-text - esm 28.22 KB (0%)
@lexical/react - cjs 39.85 KB (0%)
@lexical/react - esm 32.28 KB (0%)

kirandash added a commit to bgwebagency/lexical that referenced this pull request Feb 20, 2025
This commit fixes the issue where triple-clicking a table cell would
incorrectly select adjacent cells. The implementation is based on
@etrepum's approach from PR facebook#7005.

The fix adds two new handlers:
- Adds  to:
  - Handle triple-click events in table cells
  - Check if block's parent is a table cell
  - Select only the block within the cell
  - Prevent selection of adjacent cells
- Adds removeTripleClickHandler to:
  - Prevent default browser behavior for triple clicks
  - Use capture phase for event listeners
  - Handle all clicks >= 3 consistently

Both handlers work together to ensure proper table cell selection
behavior without affecting adjacent cells.

Fixes facebook#6973

Co-authored-by: Bob Ippolito <bob@redivi.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Selection of table cell is accompanied by selection of adjacent cell too

2 participants