Skip to content

Fix: show toolbar on double tap in QuillEditor #2600

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

shivansh00011
Copy link

🐛 Bug Fix

Issue: Double tap on text in QuillEditor doesn't show the paste field/context menu, unlike Flutter's native TextField.

Related Issue: Issue #2594

�� Problem Analysis

When users double-tap on text in QuillEditor:

  • ✅ First tap: Field focuses correctly
  • ❌ Second tap: Paste field/context menu doesn't appear
  • ✅ Expected: Paste field should appear (like in Flutter's TextField)

The issue occurs because the selection overlay is disposed immediately when the selection becomes collapsed after word selection, preventing the toolbar from being displayed.

🛠️ Solution

Modified the _updateOrDisposeSelectionOverlayIfNeeded() method in lib/src/editor/raw_editor/raw_editor_state.dart to:

  • Delay disposal of selection overlay when selection is collapsed
  • Allow toolbar display even when selection is collapsed
  • Maintain existing functionality for all other scenarios

Key Changes

// Before: Selection overlay disposed immediately when collapsed
if (!_hasFocus || textEditingValue.selection.isCollapsed) {
  _selectionOverlay!.dispose();
  _selectionOverlay = null;
}

// After: Only dispose when no toolbar is shown
if (!_hasFocus) {
  _selectionOverlay!.dispose();
  _selectionOverlay = null;
} else if (textEditingValue.selection.isCollapsed && _selectionOverlay!.toolbar == null) {
  // Only dispose when selection is collapsed and no toolbar is shown
  _selectionOverlay!.dispose();
  _selectionOverlay = null;
}

✅ Testing

  • Added test: test/double_tap_toolbar_test.dart verifies toolbar appears on double tap
  • Existing tests pass: Clipboard, context menu, and other functionality unaffected
  • Manual testing: Confirmed behavior matches Flutter's native TextField

🎯 Impact

  • Fixes: Double tap now shows paste field/context menu
  • Maintains: All existing functionality (long press, selection, etc.)
  • Improves: User experience consistency with native Flutter widgets
  • No breaking changes: Backward compatible

📋 Checklist

  • Bug fix (non-breaking change which fixes an issue)
  • New test added (or existing test updated)
  • All existing tests pass
  • Code follows the project's style guidelines
  • Self-review of code completed
  • Documentation updated (if applicable)

🔗 Related

  • Closes #[Issue Number]
  • Addresses user feedback about inconsistent behavior with native TextField

…ste field/context menu doesn't appear on double tap - Modifies selection overlay disposal logic to allow toolbar display when selection is collapsed - Adds test to verify double tap toolbar functionality - Matches behavior of Flutter's native TextField
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.

1 participant