One more issue related to 1.9.0-beta01 'Text conte...
# compose-web
p
One more issue related to 1.9.0-beta01 'Text context menu' in mobile browser When press on text field Software keyboard is not appearing When long press on text field context menu appeared with all actions disabled and it is impossible to hide it
1
b
(just my 2c, it's great that you're reporting this here, but I think you should definitely also open issues in the bug tracker if you haven't done so already)
p
I will. Just waiting for reply if it is known issue or not (cause of Beta it may be WIP).
👍 1
e
Thanks again for the report, but, unfortunately, I couldn't reproduce this issue at the moment quickly Could you please create a bug in the bug tracker with simple reproducer and provide more details such as: TextField or BasicTextField, Android or iOS etc) Also did you try using secure https mode on browser, if you in insecure mode the context menu will not work correctly
p
I'm using insecure (http) connection. I'll create an issue.
thank you color 1
e
It is a security limitation, please try in secure mode as well
p
It is ok if in insecure mode context menu will not be shown. But it is shown with disabled actions and software keyboard is not expanded on text field focused.
e
Is "Select all" option unavailable for you in insecure mode? I also couldn't reproduce the bug with the virtual keyboard:
p
Yes, Select all is available, also i can see Copy, Paste and Cut But all of them are disabled
Trying on Firefox, Brave and Chrome. Behaviour is the same
e
Still disabled even after 'Select all' or selecting part of the text?
p
I'm testing with empty text field. Long press on text field area. Expect context menu not showing at all. Will try with some text.
With existing text it is possible to select all and then Copy and Paste actions become enabled. When tap on any of these actions they perform and context menu hides. But it is impossible in any case (selected text or not) to hide this context menu when tap outside of it on none focusable area. Only when tap on focusable element (this or other text field for example), then it becomes hidden
Paste action is always disabled (may be cause of security issue)
👌 1
@Ekaterina Zaitseva Is compose multiplatform wasm demo (your video) in some public repo? I can clone it and test on my mobile.
e
But it is impossible in any case (selected text or not) to hide this context menu when tap outside of it on none focusable area.
In this demo it works, it depends on implementation using pointerInput
p
What does it mean?
e
For example:
Copy code
var f1 by remember { mutableStateOf("") }
                    val focusRequester = remember { FocusRequester() }
                    val keyboardController = LocalSoftwareKeyboardController.current
                    val focusManager = LocalFocusManager.current
                    val textFieldInteractionSource = remember { MutableInteractionSource() }

                    Box(
                        modifier = Modifier
                            .fillMaxSize()
                            .pointerInput(Unit) {
                                awaitEachGesture {
                                    val event = awaitPointerEvent()
                                    if (event.type == PointerEventType.Press) {
                                        // Hide keyboard when tapping outside the TextField
                                        keyboardController?.hide()
                                        // Clear focus
                                        focusManager.clearFocus()
                                    }
                                }
                            }
                    ) {
                        OutlinedTextField(
                            modifier = Modifier
                                .focusRequester(focusRequester)
                                .align(Alignment.Center),
                            value = f1,
                            onValueChange = { f1 = it },
                            keyboardOptions = KeyboardOptions(imeAction = ImeAction.Done),
                            keyboardActions = KeyboardActions(
                                onDone = {
                                    keyboardController?.hide()
                                }
                            ),
                            interactionSource = textFieldInteractionSource
                        )
                    }

                    LaunchedEffect(Unit) {
                        delay(1000)
                        focusRequester.requestFocus()
                    }
p
I thought it should work out of the box.
e
Unfortunately no, should be implemented
p
Found difference. I'm using CanvasBasedWindow. When switched to ComposeViewport keyboard problem gone. @Ekaterina Zaitseva thanks for help!
thank you color 1
e
Thank you for sharing this! It's really valuable info