Skip to content

Commit

Permalink
issue: 227 Automaticaly collapse after redirecting to the desired page (
Browse files Browse the repository at this point in the history
  • Loading branch information
Vivek-04022001 authored Oct 11, 2023
1 parent c3db58c commit c502286
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
8 changes: 7 additions & 1 deletion components/Picker/LanguagePicker.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { faChevronDown } from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { useState } from "react";
import { useEffect, useState } from "react";
import { CountableTag } from "../../types";
import { SectionTitle } from "../SectionTitle";
import { PickerItem } from "./PickerItem";
Expand All @@ -14,6 +14,12 @@ type LanguagePickerProps = {
export const LanguagePicker = ({ activeTagId, languages, onLanguagePage }: LanguagePickerProps) => {
const [isCollapsed, setIsCollapsed] = useState<boolean>(true);

// Automatically collapse the sidebar after redirection
useEffect(() => {
setIsCollapsed(true);
}, [onLanguagePage, activeTagId]);

// Toggle the collapsible sidebar
const toggleCollapsible = () => {
setIsCollapsed(!isCollapsed);
};
Expand Down
8 changes: 7 additions & 1 deletion components/Picker/TagPicker.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { faChevronDown } from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { useState } from "react";
import { useState,useEffect } from "react";
import { CountableTag } from "../../types";
import { ShowMoreButton } from "../Button/ShowMoreButton";
import { SectionTitle } from "../SectionTitle";
Expand All @@ -20,6 +20,11 @@ export const TagPicker = ({ tags, activeTagId, onTagPage }: TagPickerProps) => {

const [isCollapsed, setIsCollapsed] = useState<boolean>(true);

// Automatically collapse the sidebar after redirection
useEffect(() => {
setIsCollapsed(true);
}, [activeTagId]);

const toggleCollapsible = () => {
setIsCollapsed(!isCollapsed);
};
Expand All @@ -35,6 +40,7 @@ export const TagPicker = ({ tags, activeTagId, onTagPage }: TagPickerProps) => {
setShowMore(!showMore);
};


return (
<div className="pt-6">
<div
Expand Down

0 comments on commit c502286

Please sign in to comment.