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

fix: separate _onDayPress from _onCalendarListDayPress & block unrelated taps with height based _isOpen. #2614

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ucaboro
Copy link

@ucaboro ucaboro commented Mar 5, 2025

description
We are resetting the week calendar in bounceToPosition with resetWeekCalendarOpacity(_isOpen) before the animation completes. It is based on height tracking rather than position local state. This creates a discrepancy between what you see in UI (_isOpen) and what gets tapped on (that is position-based isOpen) causing unintended day changes when the different view is tapped while animation complete callback is not run.

extra
We could have moved setPosition outside the Animated callback and put it together with resetWeekCalendarOpacity (like in below snippet), which would sync the view with what position actually is, but this would destroy the animation (which I think is nice). Hence the main fix is around blocking unintended taps (taps that are different from what you see) and only process those taps that happen after the animation completes and setPosition is updated.

    const bounceToPosition = (toValue = 0) => {
        if (!disablePan) {
            const threshold = isOpen ? openHeight.current - closeThreshold : closedHeight + openThreshold;
            let _isOpen = _height.current >= threshold;
            const newValue = _isOpen ? openHeight.current : closedHeight;
            deltaY.setValue(_height.current); // set the start position for the animated value
            _height.current = toValue || newValue;
            _isOpen = _height.current >= threshold; // re-check after _height.current was set
            resetWeekCalendarOpacity(_isOpen);
            setPosition(() => _height.current === closedHeight ? Positions.CLOSED : Positions.OPEN);
            Animated.spring(deltaY, {
                toValue: _height.current,
                speed: SPEED,
                bounciness: BOUNCINESS,
                useNativeDriver: false,
            }).start(() => {
                onCalendarToggled?.(_isOpen);
            });
            closeHeader(_isOpen);
        }
    };

…ted taps with height based _isOpen.

desc: We are resetting the week calendar in bounceToPosition with resetWeekCalendarOpacity(_isOpen) before the animation completes. It is based on height tracking rather than position local state. This creates a discrepancy between what you see in UI (_isOpen) and what gets tapped on (that is position-based isOpen) causing unintended day changes when the different view is tapped while animation complete callback is not run.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant