Expose textFieldValue and onTextFieldValueChange as public API#644
Open
tomkoptel wants to merge 1 commit intoMohamedRejeb:mainfrom
Open
Expose textFieldValue and onTextFieldValueChange as public API#644tomkoptel wants to merge 1 commit intoMohamedRejeb:mainfrom
tomkoptel wants to merge 1 commit intoMohamedRejeb:mainfrom
Conversation
Make `textFieldValue` and `onTextFieldValueChange` public on `RichTextState` to enable custom `BasicTextField` wrappers that intercept value changes before they are committed. Use case: mention/hashtag systems need synchronous interception of text changes to protect mention tokens from partial deletion (e.g., backspace at the end of "@john Doe" should remove the entire mention, not just the last character). This behavior mirrors Compose Text 2's `InputTransformation` but for the old `BasicTextField(value, onValueChange)` API that `BasicRichTextEditor` wraps. Without this, consumers must use reflection to access these members, which is fragile across library versions and breaks with R8/ProGuard. Changes: - `internal var textFieldValue` → `public var textFieldValue` - `internal fun onTextFieldValueChange` → `public fun onTextFieldValueChange`
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
textFieldValuepublic (wasinternal) onRichTextStateonTextFieldValueChangepublic (wasinternal) onRichTextStateMotivation
When building mention/hashtag systems on top of
BasicRichTextEditor, consumers need synchronous interception of text changes to protect mention tokens from partial deletion. For example, pressing backspace at the end of@John Doeshould remove the entire mention in one go, not just the last character.This behavior mirrors Compose Text 2's
InputTransformationbut for the oldBasicTextField(value, onValueChange)API thatBasicRichTextEditorwraps.The typical pattern is to wrap
BasicTextFielddirectly with a customonValueChangethat inspects the change, modifies it if needed, then forwards tostate.onTextFieldValueChange():Without public access to these members, consumers must use reflection which is fragile across library versions and breaks with R8/ProGuard optimizations.
Changes
2 lines changed in
RichTextState.kt:internal var textFieldValue→public var textFieldValueinternal fun onTextFieldValueChange→public fun onTextFieldValueChangeNo behavioral changes. No new APIs. Just visibility.