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

[MaterialDatePicker] (Compose) _Today_ is not visually disabled even if it's outside of selectable range #4264

Open
lwasyl opened this issue Aug 19, 2024 · 1 comment

Comments

@lwasyl
Copy link

lwasyl commented Aug 19, 2024

Description: If I build a material date picker with selectable range of today+1 day, whatever, then today day on the picker has no indication that it's not selectable. Here, Aug 19 is not selectable as per picker range, and disabledDayContentColor is red:
image

Expected behavior: Not clickable elements are visually disabled

Source code:

    @Composable
    internal fun dayContentColor(
        isToday: Boolean,
        selected: Boolean,
        inRange: Boolean,
        enabled: Boolean
    ): State<Color> {
        val target =
            when {
                selected && enabled -> selectedDayContentColor
                selected && !enabled -> disabledSelectedDayContentColor
                inRange && enabled -> dayInSelectionRangeContentColor
                inRange && !enabled -> disabledDayContentColor
                isToday -> todayContentColor
                enabled -> dayContentColor
                else -> disabledDayContentColor
            }

        return if (inRange) {
            rememberUpdatedState(target)
        } else {
            // Animate the content color only when the day is not in a range.
            animateColorAsState(target, tween(durationMillis = MotionTokens.DurationShort2.toInt()))
        }
    }

In the source the first two clauses are false because today is not selected, following two are also false because it's not in selectable range either. But isToday is true so the picked color is todayContentColor even though the day is also not enabled.

image

image

image

Minimal sample app repro: trivially reproducible

Android API version: Api 34

Material Library version: Compose dev.chrisbanes.compose:compose-bom:2024.08.00-alpha01

Device: emulator

To help us triage faster, please check to make sure you are using the latest version of the library.

We also happily accept pull requests.

@RivanParmar
Copy link

Seems like you opened the issue in the wrong repository. This repository is for Material Components for Views and not for Compose. The Compose code is contained at androidx. Please refer to the docs there for submitting your issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants