mduppes commited on
Commit
b92592b
·
1 Parent(s): 761ec97

Reset state on tab change

Browse files
frontend/src/components/Examples.tsx CHANGED
@@ -39,6 +39,11 @@ const Examples = ({ fileType }: ExamplesProps) => {
39
 
40
  useEffect(() => {
41
  descriptions.current.load().then(() => setDescriptionsLoaded(true))
 
 
 
 
 
42
  // Fetch datasets when component loads
43
  API.fetchDatasets().then((datasetsData) => {
44
  setDatasets(datasetsData)
@@ -90,6 +95,9 @@ const Examples = ({ fileType }: ExamplesProps) => {
90
 
91
  setLoading(true)
92
  setError(null)
 
 
 
93
  API.fetchExamplesByType(fileType, selectedDataset)
94
  .then((data) => {
95
  setExamples(data)
 
39
 
40
  useEffect(() => {
41
  descriptions.current.load().then(() => setDescriptionsLoaded(true))
42
+ // Reset selectors and error when fileType changes
43
+ setSelectedModel(null)
44
+ setSelectedAttack(null)
45
+ setExamples({})
46
+ setError(null)
47
  // Fetch datasets when component loads
48
  API.fetchDatasets().then((datasetsData) => {
49
  setDatasets(datasetsData)
 
95
 
96
  setLoading(true)
97
  setError(null)
98
+ // Reset selectors when selectedDataset changes
99
+ setSelectedModel(null)
100
+ setSelectedAttack(null)
101
  API.fetchExamplesByType(fileType, selectedDataset)
102
  .then((data) => {
103
  setExamples(data)
frontend/src/components/LeaderboardChart.tsx CHANGED
@@ -162,6 +162,9 @@ const LeaderboardChart = ({ dataset, selectedModels, datasetType }: LeaderboardC
162
 
163
  useEffect(() => {
164
  setLoading(true)
 
 
 
165
  API.fetchStaticFile(`data/${dataset}?dataset_type=attacks_variations`)
166
  .then((response) => {
167
  const data = JSON.parse(response)
 
162
 
163
  useEffect(() => {
164
  setLoading(true)
165
+ // Reset selectors when dataset changes
166
+ setSelectedMetric(null)
167
+ setSelectedAttack(null)
168
  API.fetchStaticFile(`data/${dataset}?dataset_type=attacks_variations`)
169
  .then((response) => {
170
  const data = JSON.parse(response)
frontend/src/components/LeaderboardPage.tsx CHANGED
@@ -22,6 +22,9 @@ const LeaderboardPage: React.FC<LeaderboardPageProps> = ({ datasetType }) => {
22
  // Fetch dataset names from backend on mount or when datasetType changes
23
  useEffect(() => {
24
  setLoading(true)
 
 
 
25
  API.fetchDatasets()
26
  .then((grouped) => {
27
  const filtered = grouped[datasetType] || []
 
22
  // Fetch dataset names from backend on mount or when datasetType changes
23
  useEffect(() => {
24
  setLoading(true)
25
+ // Reset selectors when datasetType changes
26
+ setSelectedModels(new Set())
27
+ setBenchmarkData(null)
28
  API.fetchDatasets()
29
  .then((grouped) => {
30
  const filtered = grouped[datasetType] || []