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

Timeline calendar num of days issues #2080

Merged
merged 12 commits into from Nov 28, 2022

Conversation

yuvalsho
Copy link
Contributor

@yuvalsho yuvalsho commented Nov 7, 2022

fixed issues:

  1. selected day marking appears as opposed to the guideline which doesn't show the selected date
  2. when scrolling week from the timeline sometimes it doesn't change the date
  3. when updating numOfSays the component doesn't re-render properly

src/dateutils.ts Outdated Show resolved Hide resolved
@Inbal-Tish Inbal-Tish self-assigned this Nov 16, 2022
@@ -174,12 +174,17 @@ const ExpandableCalendar = (props: ExpandableCalendarProps) => {
return CLOSED_HEIGHT + (WEEK_HEIGHT * (numberOfWeeks.current - 1)) + (hideKnob ? 12 : KNOB_CONTAINER_HEIGHT) + (constants.isAndroid ? 3 : 0);
};
const openHeight = useRef(getOpenHeight());
const closedHeight = useRef(CLOSED_HEIGHT + (hideKnob || Number(numberOfDays) > 1 ? 0 : KNOB_CONTAINER_HEIGHT));
const closedHeight = useMemo(() => CLOSED_HEIGHT + (hideKnob || Number(numberOfDays) > 1 ? 0 : KNOB_CONTAINER_HEIGHT), [numberOfDays]);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing dep 'hideKnob'

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added the dep


const startHeight = isOpen ? openHeight.current : closedHeight.current;
const startHeight = useMemo(() => isOpen ? openHeight.current : closedHeight, [closedHeight]);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing dep 'isOpen'

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually I'm not sure memoizing this is a good idea as it affects other non-memoized consts

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it affects memoized consts or is used as an initializer for useRef references, also added the missing dep

}
}
prevDate.current = date;
}, [pagesRef.current, updateSource]);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pagesRef.current is not dep...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not? it changes when the number of days changes (since when numOfDay = undefined we have a page for each day and when the number of days = 3 we have a page for every 3 days), when the scroll doesn't adjust to it we get an issue with the scrolling (it thinks that it scrolled 3 pages instead of 1 because of the pagesRef old value being used

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mutable values like 'something.current' aren't valid dependencies because mutating them doesn't re-render the component.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed unnecessary dependency

@Inbal-Tish
Copy link
Collaborator

Inbal-Tish commented Nov 21, 2022

@yuvalsho I don't understand how the changes in Expandable/index regarding the height and closed mechanized relate to this PR? Are there other issues you're fixing here?

src/dateutils.ts Outdated
}
}

export function sameDayRange({
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'onSameDateRange', no?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

renamed

useDidUpdate(() => {
if (updateSource !== UpdateSources.WEEK_SCROLL) {
const pageIndex = items.current.findIndex(item => sameWeek(item, date, firstDay));
const pageIndex = items.current.findIndex(
item => (numberOfDays && numberOfDays > 1) ?
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better move this condition (numberOfDays && numberOfDays > 1) to a const since you're using the same one later in line 250

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extracted to a function (it's used outside of the component so it cant be a const/memoized)

@@ -3,10 +3,10 @@ const {toMarkingFormat} = require('./interface');


export function getState(day: XDate, current: XDate, props: any) {
const {minDate, maxDate, disabledByDefault, context} = props;
const {minDate, maxDate, disabledByDefault, context, disableDaySelection} = props;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is disableDaySelection part of the 'props' if it's not a prop? It's confusing, why not add an option object or another pharam?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i agree, moved to be a different parameter

src/dateutils.ts Outdated
}
}

export function onSameDAteRange({
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The "A" on Date is capitalized... typo I guess

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@yuvalsho yuvalsho merged commit 077cd13 into master Nov 28, 2022
@yuvalsho yuvalsho deleted the timeline-calendar-num-of-days-issues branch November 28, 2022 08:24
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.

None yet

2 participants