Skip to content

Android: Disable selection ActionMode without visual flash (Dialog-safe)#634

Open
NavCore wants to merge 17 commits intoMohamedRejeb:mainfrom
NavCore:main
Open

Android: Disable selection ActionMode without visual flash (Dialog-safe)#634
NavCore wants to merge 17 commits intoMohamedRejeb:mainfrom
NavCore:main

Conversation

@NavCore
Copy link

@NavCore NavCore commented Jan 17, 2026

Problem

When using RichTextEditor inside a Compose Dialog on Android, setting
disableSelectionToolbar = true hides the cut/copy/paste toolbar,
but the Android ActionMode still appears briefly (one-frame flash)
before being dismissed.

This happens because the ActionMode is created at the Window level
before Compose can suppress it.


Solution

This PR introduces an Android-only fix that fully intercepts ActionMode
creation at the Window level:

  • Wraps the Dialog Window.Callback
  • Overrides onWindowStartingActionMode(...)
  • Returns a NoOp ActionMode with an empty Menu
  • Prevents the toolbar from being created at all (no flash)
  • Applies only when disableSelectionToolbar = true

Key Points

  • ✅ No AppCompat dependency
  • ✅ Android-only (androidMain)
  • ✅ Safe for Compose Dialogs (DialogWindowProvider)
  • ✅ Default behavior unchanged when flag is false
  • ✅ No impact on desktop / iOS / JS targets

Files Changed

  • ProvideNoSelectionToolbar.android.kt
    • Window-level ActionMode interception
    • NoOp ActionMode + empty Menu implementation

Result

Cut / copy / paste toolbar is completely disabled
with zero visual artifacts, even on long-press or word selection.


Thanks for the great library!
This fix enables clean read-only / note-taking use cases on Android.

…events the

platform selection toolbar (ActionMode: cut/copy/paste) from being shown while
keeping editing, cursor, and selection handles functional.

This is useful for apps that want custom in-editor controls and no system toolbar.
Default behavior remains unchanged (disabled by default).
- Avoid Android-only APIs in commonMain (fixes JitPack/KMP metadata build)
- Add expect/actual ProvideNoSelectionToolbar wrapper
- Android uses LocalTextToolbar no-op, other targets are pass-through
JitPack does not provide signing credentials, which caused the
Android publication task to fail during release builds.

This change disables signing for Android publications when
credentials are not available, allowing the library to be
successfully built and published by JitPack.

No runtime or API changes are introduced.
…l flash

- Intercept Android ActionMode at Window level for RichTextEditor
- Provide NoOp ActionMode with empty Menu to prevent cut/copy/paste UI
- Apply fix only when disableSelectionToolbar = true
- Keep default behavior unchanged when flag is false
- No AppCompat dependency, Android-only implementation
- Works correctly inside Compose Dialogs (DialogWindowProvider)
- add minHeight and maxHeight params to RichTextEditor wrappers
- remove hardcoded TextFieldDefaults.MinHeight from modifiers
- apply heightIn() so editor can be sized relative to parent
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