Skip to content
New issue

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

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

Already on GitHub? # to your account

Fix IME candidate popup position for BasicTextField2 #1794

Merged
merged 1 commit into from
Jan 29, 2025

Conversation

m-sasha
Copy link
Member

@m-sasha m-sasha commented Jan 23, 2025

PlatformTextInputSession.platformSpecificTextInputSession now calls DesktopTextInputService.notifyFocusedRect to tell the system where to place the IME candidate window for languages such as Chinese.

Fixes https://youtrack.jetbrains.com/issue/CMP-7467

image

Testing

  • Added testing with BasicTextField2 to WindowTypingLocationTest.
  • Tested manually with:
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.text.input.rememberTextFieldState
import androidx.compose.material.*
import androidx.compose.runtime.*
import androidx.compose.ui.*
import androidx.compose.ui.unit.*
import androidx.compose.ui.window.*

fun main() = singleWindowApplication {
    Column(
        Modifier.fillMaxSize().padding(16.dp),
    ) {
        Text("TextField")
        var value by remember { mutableStateOf("") }
        TextField(value = value, onValueChange = { value = it }, modifier = Modifier.width(200.dp))

        Spacer(Modifier.height(64.dp))
        Text("TextField2")
        val state = rememberTextFieldState()
        TextField(state, modifier = Modifier.width(200.dp))
    }
}

This should be tested by QA

Release Notes

Fixes - Desktop

  • Fixed the positioning of the IME candidate popup for TextField(TextFieldState) (aka BasicTextField2).

@m-sasha m-sasha requested review from MatkovIvan and igordmn January 23, 2025 13:30
@m-sasha
Copy link
Member Author

m-sasha commented Jan 23, 2025

Two reviewers due to the addition of PlatformTextInputSession.notifyFocusedRect.

@m-sasha m-sasha force-pushed the m-sasha/fix-ime-window-position branch from 0803741 to c15e398 Compare January 24, 2025 09:35
@ExperimentalComposeUiApi
fun updateSelectionState(newState: TextFieldValue) = Unit

@ExperimentalComposeUiApi
fun notifyFocusedRect(rect: Rect) = Unit
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not only desktop change, but I see only Desktop related tests. How does it work for iOS? Web?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be a desktop-only change. The other platforms don't implement the new method.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about web? It seems that they need to implement something like this.

cc @Schahen to check if web should be affected or not
cc @mazunin-v-jb to confirm that iOS doesn't need this functionality in any form

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

iOS will need that, but for now, iOS doesn't use that method. There's no need to implement it here, I'll do it later myself

…tField2 (PlatformTextInputSession.platformSpecificTextInputSession).
@m-sasha m-sasha force-pushed the m-sasha/fix-ime-window-position branch from c15e398 to 804fa1c Compare January 25, 2025 13:04
@m-sasha m-sasha requested a review from MatkovIvan January 25, 2025 15:51
Copy link
Collaborator

@igordmn igordmn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checked the snippet on Windows - works as well

@m-sasha m-sasha merged commit 63bfb5d into jb-main Jan 29, 2025
7 checks passed
@m-sasha m-sasha deleted the m-sasha/fix-ime-window-position branch January 29, 2025 14:28
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants