compose-multiplatform icon indicating copy to clipboard operation
compose-multiplatform copied to clipboard

Consider deprecation of `TooltipArea` in favor of `BasicTooltipBox` when it is no longer experimental

Open igordmn opened this issue 1 year ago • 3 comments

And move all necessary functionality there.

There should be only one non-experiemental way to show tooltips.

    @OptIn(ExperimentalFoundationApi::class)
    @Composable
    fun Content() {
        BasicTooltipBox(
            positionProvider = TooltipDefaults.rememberPlainTooltipPositionProvider(),
            tooltip = {
                androidx.compose.material3.Text("Add to favorites")
            },
            state = rememberBasicTooltipState()
        ) {
            IconButton(
                onClick = { /* Icon button's click event */ }
            ) {
                androidx.compose.material3.Icon(
                    imageVector = Icons.Filled.Favorite,
                    contentDescription = "Localized Description"
                )
            }
        }
    }

Check also, how TooltipBox works. One of the known issues - it has isPersistent = false by default, which works bad on desktop.

igordmn avatar Feb 09 '24 22:02 igordmn

Investigated BasicTooltipBox a bit. It doesn't seem suitable for desktop needs.

✅ I'm not sure what isPersistent does as it doesn't seem to have an effect on the desktop. Tooltips disappear immediately when the mouse cursor leaves the box. ❌ Tooltips appear immediately, without delay, when the mouse pointer is moved into the box. ❌ The positionProvider argument isn't documented properly. The user is left to guess where he could obtain a useful implementation (rememberComponentRectPositionProvider is one) ❌ There's no positionProvider implementation equivalent to TooltipPlacement.CursorPoint. rememberCursorPositionProvider remembers the position of the mouse pointer at the time of invocation.

m-sasha avatar Feb 19 '24 12:02 m-sasha

The same comments apply to TooltipBox (which is also only available in material3).

m-sasha avatar Feb 19 '24 12:02 m-sasha

Related: #4321

MatkovIvan avatar Feb 19 '24 13:02 MatkovIvan

I see there's TooltipDefaults.rememberPlainTooltipPositionProvider which only positions the tooltip above the box.

m-sasha avatar Feb 19 '24 14:02 m-sasha

TooltipArea was designed for desktopMain and works well, but having 2 similar available API's doing one thing isn't good from the user perspective. We need to merge functionality with BasicTooltipBox (or with something else that will be instead of it)

igordmn avatar Feb 19 '24 15:02 igordmn