enabled accordion to be collapsed
This commit is contained in:
@@ -18,8 +18,9 @@ export const MonthCard:FC<MonthCardProps> = ({ yearMonth, children, monthlyExpen
|
|||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const elRef = useRef<HTMLDivElement>(null);
|
const elRef = useRef<HTMLDivElement>(null);
|
||||||
|
|
||||||
// setting the `month` will activate the accordion belonging to that month
|
// Setting the `month` will activate the accordion belonging to that month
|
||||||
const handleChange = (event:any) => router.push(`/?year=${yearMonth.year}&month=${yearMonth.month}`);
|
// If the accordion is already active, it will collapse it
|
||||||
|
const handleChange = (event:any) => router.push(expanded ? `/?year=${yearMonth.year}` : `/?year=${yearMonth.year}&month=${yearMonth.month}`);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if(expanded && elRef.current) {
|
if(expanded && elRef.current) {
|
||||||
|
|||||||
Reference in New Issue
Block a user