Fixed
Status Update
Comments
cl...@google.com <cl...@google.com>
ma...@google.com <ma...@google.com> #2
Thanks for filing this.
This is slightly more tricky due to design of the swipeable and it's a hard requirement for it to be attached to the component.
I considered no-op to be a consistent behaviour as well (since it's how the rest of the states will work when developer don't pass them), but maybe exception is even better.
I will add a message to the swipeable, this should cover scaffold case (however it will say that DrawerState is not attached, since you're opening the drawer), Drawers, backdrops and other swipeable components, all with sane messages.
ap...@google.com <ap...@google.com> #3
Project: platform/frameworks/support
Branch: androidx-main
commit c931ec8de18c5aa715ecb653ec4de06256f77a59
Author: Matvei Malkov <malkov@google.com>
Date: Fri Jan 15 16:14:39 2021
Add meaningful message when SwipeableState is not attached to the component.
Due to a specific design of the Swipeable, it's state is required to be passed to the component to work properly.
We're chosing a speicific crash message for now, but it might be changed to no-op in the future, we'll see.
Fixes: 175943374
Test: demos lauched + repro from bug
Change-Id: Id98b467d0a089bb924ed2b12060e062b2f17ef54
M compose/material/material/src/commonMain/kotlin/androidx/compose/material/Swipeable.kt
https://android-review.googlesource.com/1552458
Branch: androidx-main
commit c931ec8de18c5aa715ecb653ec4de06256f77a59
Author: Matvei Malkov <malkov@google.com>
Date: Fri Jan 15 16:14:39 2021
Add meaningful message when SwipeableState is not attached to the component.
Due to a specific design of the Swipeable, it's state is required to be passed to the component to work properly.
We're chosing a speicific crash message for now, but it might be changed to no-op in the future, we'll see.
Fixes: 175943374
Test: demos lauched + repro from bug
Change-Id: Id98b467d0a089bb924ed2b12060e062b2f17ef54
M compose/material/material/src/commonMain/kotlin/androidx/compose/material/Swipeable.kt
Description
Steps to Reproduce:
Expected Results: An exception mentioning something to the effect of "perhaps you forgot to provide a scaffoldState to Scaffold()".
Actual Results: An exception saying "The target value must have an associated anchor":
The sample has a bug, where
scaffoldState
is not supplied to aScaffold()
for which we are setting up a drawer:If you uncomment that line, the sample works as expected.
However, with the app bug in place... that exception is really obscure.
IMHO, ideally,
Scaffold()
does a bit more sanity-checking and provides a more focused exception for this mistake. If that proves to be impractical, maybe you could add some additional prose to the existing exception text to hint to the developer where the problem might be.Scaffold()
is likely to be popular, which means the more n00b-friendly it can be, the better off we are (again IMHO).Thanks for considering this!