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
Conversation
src/expandableCalendar/index.tsx
Outdated
@@ -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]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing dep 'hideKnob'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added the dep
src/expandableCalendar/index.tsx
Outdated
|
||
const startHeight = isOpen ? openHeight.current : closedHeight.current; | ||
const startHeight = useMemo(() => isOpen ? openHeight.current : closedHeight, [closedHeight]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing dep 'isOpen'
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
src/timeline-list/index.tsx
Outdated
} | ||
} | ||
prevDate.current = date; | ||
}, [pagesRef.current, updateSource]); |
There was a problem hiding this comment.
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...
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed unnecessary dependency
@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({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'onSameDateRange', no?
There was a problem hiding this comment.
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) ? |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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)
src/day-state-manager.ts
Outdated
@@ -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; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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({ |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
fixed issues: