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

[Web] Uncaught runtime error in Material3 DatePicker (DisplayMode.Input) when enter incorrect date #4856

Closed
denzap opened this issue May 23, 2024 · 0 comments · Fixed by JetBrains/compose-multiplatform-core#1368
Labels
bug Something isn't working material3 web

Comments

@denzap
Copy link

denzap commented May 23, 2024

Describe the bug
There is a crash (runtime error DateTimeException) when you use material3.DatePicker in DisplayMode.Input and enter incorrect date like 50/50/2024. Only reproduces in Web, all other targets work correctly.

Affected platforms

  • Web (K/Wasm) - Canvas based API
  • Web (K/JS) - Canvas based API

Versions

  • Libraries:
    • Compose Multiplatform version: 1.6.1, 1.6.10
  • Kotlin version: 1.9.23, 2.0.0

To Reproduce
Steps to reproduce the behavior:

  1. Run this code snippet:
    @Composable
    fun BugReproduction() {
        Column(Modifier.fillMaxWidth(), horizontalAlignment = Alignment.CenterHorizontally) {
            val state = rememberDatePickerState(initialDisplayMode = DisplayMode.Input)
            DatePicker(state = state)
        }
    }
  2. Enter 50/50/2024 date
  3. See error

Expected behavior
There should be no crash but the error tip like "Date does not match expected pattern" like on all other platforms

Screenshots
Web crash:
Screenshot 2024-05-23 at 11 16 28

Desktop ok:
Screenshot 2024-05-23 at 11 17 15

@denzap denzap added bug Something isn't working submitted labels May 23, 2024
eymar pushed a commit to JetBrains/compose-multiplatform-core that referenced this issue May 23, 2024
- Update kotlinx.datetime to
[0.6.0](https://github.com/Kotlin/kotlinx-datetime/releases/tag/v0.6.0)
- Migrate locale-invariant web formatting/parsing to kotlinx.datetime
- Catch parsing exceptions

<!-- Optional -->
Fixes JetBrains/compose-multiplatform#4856

## Testing

`KotlinxDatetimeCalendarModelTest.illegalDateParsingDoesNotThrowException`

<!-- Optional -->
This should be tested by QA

## Release Notes

### Fixes - Web
- Fixed crash when date picker text field receives illegal input
MatkovIvan pushed a commit to JetBrains/compose-multiplatform-core that referenced this issue May 29, 2024
- Update kotlinx.datetime to
[0.6.0](https://github.com/Kotlin/kotlinx-datetime/releases/tag/v0.6.0)
- Migrate locale-invariant web formatting/parsing to kotlinx.datetime
- Catch parsing exceptions

<!-- Optional -->
Fixes JetBrains/compose-multiplatform#4856

## Testing

`KotlinxDatetimeCalendarModelTest.illegalDateParsingDoesNotThrowException`

<!-- Optional -->
This should be tested by QA

## Release Notes

### Fixes - Web
- Fixed crash when date picker text field receives illegal input
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working material3 web
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants