Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Setting a modifier on the splitter makes it crash #2214

Closed
rock3r opened this issue Jul 28, 2022 · 2 comments · Fixed by #2886
Closed

Setting a modifier on the splitter makes it crash #2214

rock3r opened this issue Jul 28, 2022 · 2 comments · Fixed by #2886
Assignees
Labels
bug Something isn't working component

Comments

@rock3r
Copy link
Contributor

rock3r commented Jul 28, 2022

If you set a modifier on a Splitter, it crashes with something like this:

Exception in thread "main" java.lang.IllegalArgumentException: Cannot coerce value to an empty range: maximum 1004.0 is less than minimum 1358.0.
	at kotlin.ranges.RangesKt___RangesKt.coerceIn(_Ranges.kt:1263)
	at org.jetbrains.compose.splitpane.DesktopSplitPaneKt$SplitPane$5.measure-3p2s80s(DesktopSplitPane.kt:80)
        ...

You can repro with something like this:

@Composable
fun EntryPoint() {
    Row(Modifier.fillMaxSize()) {
        MyComposable(Modifier.weight(1f).fillMaxWidth())
    }
}

@Composable
fun MyComposable(modifier: Modifier = Modifier) {
    HorizontalSplitPane(modifier) {
        first(minSize = minSizeLeft) {
            Box(Modifier.fillMaxSize().background(Color.Blue))
        }
        second(minSize = minSizeLeft) {
            Box(Modifier.fillMaxSize().background(Color.Red))
        }
        splitter {
            handle {
                Box(
                    Modifier
                        .markAsHandle()
                        .pointerHoverIcon(PointerIcon(Cursor(Cursor.E_RESIZE_CURSOR)))
                        .width(10.dp)
                        .fillMaxHeight()
                )
            }
        }
    }
}

If you change the HorizontalSplitPane invocation dropping the modifier, it works fine.

@rock3r rock3r added bug Something isn't working component labels Jul 28, 2022
@rock3r
Copy link
Contributor Author

rock3r commented Jul 28, 2022

You can also make it work by removing the fillMaxWidth() modifier in EntryPoint

@okushnikov
Copy link

Please check the following ticket on YouTrack for follow-ups to this issue. GitHub issues will be closed in the coming weeks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working component
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants