From c89dfe2967cf0d5c390a0f50c708b502d09d311f Mon Sep 17 00:00:00 2001 From: immanuwell Date: Sat, 30 May 2026 22:12:14 +0400 Subject: [PATCH] fix: remove missing resize event listener cleanup and fix copy button aria-label Signed-off-by: immanuwell --- src/components/clusters/index.tsx | 4 +++ src/components/clusters/schedulers/index.tsx | 33 ++++++++++--------- src/components/clusters/seed-peers/index.tsx | 33 ++++++++++--------- src/components/developer/tokens/index.tsx | 2 +- .../persistent-cache-task/cluster/index.tsx | 4 +++ .../information/index.tsx | 4 +++ 6 files changed, 49 insertions(+), 31 deletions(-) diff --git a/src/components/clusters/index.tsx b/src/components/clusters/index.tsx index c9d78689..5ab99507 100644 --- a/src/components/clusters/index.tsx +++ b/src/components/clusters/index.tsx @@ -129,6 +129,10 @@ export default function Clusters() { setTotalPages(totalPage); setAllClusters(currentPageData); + + return () => { + window.removeEventListener('resize', updatePageSize); + }; } else if (cluster === null || cluster) { setTotalPages(1); setAllClusters([]); diff --git a/src/components/clusters/schedulers/index.tsx b/src/components/clusters/schedulers/index.tsx index 90ee75a8..42c1d4d3 100644 --- a/src/components/clusters/schedulers/index.tsx +++ b/src/components/clusters/schedulers/index.tsx @@ -227,23 +227,22 @@ export default function ShowCluster() { } }); - if (alignment === 'card') { - const updatePageSize = () => { - if (window.matchMedia('(max-width: 1440px)').matches) { - setPageSize(9); - } else if (window.matchMedia('(max-width: 1600px)').matches) { - setPageSize(9); - } else if (window.matchMedia('(max-width: 1920px)').matches) { - setPageSize(12); - } else if (window.matchMedia('(max-width: 2048px)').matches) { - setPageSize(12); - } else if (window.matchMedia('(max-width: 2560px)').matches) { - setPageSize(15); - } - }; + const updatePageSize = () => { + if (window.matchMedia('(max-width: 1440px)').matches) { + setPageSize(9); + } else if (window.matchMedia('(max-width: 1600px)').matches) { + setPageSize(9); + } else if (window.matchMedia('(max-width: 1920px)').matches) { + setPageSize(12); + } else if (window.matchMedia('(max-width: 2048px)').matches) { + setPageSize(12); + } else if (window.matchMedia('(max-width: 2560px)').matches) { + setPageSize(15); + } + }; + if (alignment === 'card') { updatePageSize(); - window.addEventListener('resize', updatePageSize); } @@ -277,6 +276,10 @@ export default function ShowCluster() { setSchedulerTotalPages(totalPage); setAllSchedlers(currentPageData); + + return () => { + window.removeEventListener('resize', updatePageSize); + }; } else { setSchedulerTotalPages(1); setAllSchedlers([]); diff --git a/src/components/clusters/seed-peers/index.tsx b/src/components/clusters/seed-peers/index.tsx index c4118db5..601b7ac6 100644 --- a/src/components/clusters/seed-peers/index.tsx +++ b/src/components/clusters/seed-peers/index.tsx @@ -211,23 +211,22 @@ export default function ShowCluster() { } }); - if (alignment === 'card') { - const updatePageSize = () => { - if (window.matchMedia('(max-width: 1440px)').matches) { - setPageSize(9); - } else if (window.matchMedia('(max-width: 1600px)').matches) { - setPageSize(9); - } else if (window.matchMedia('(max-width: 1920px)').matches) { - setPageSize(12); - } else if (window.matchMedia('(max-width: 2048px)').matches) { - setPageSize(12); - } else if (window.matchMedia('(max-width: 2560px)').matches) { - setPageSize(15); - } - }; + const updatePageSize = () => { + if (window.matchMedia('(max-width: 1440px)').matches) { + setPageSize(9); + } else if (window.matchMedia('(max-width: 1600px)').matches) { + setPageSize(9); + } else if (window.matchMedia('(max-width: 1920px)').matches) { + setPageSize(12); + } else if (window.matchMedia('(max-width: 2048px)').matches) { + setPageSize(12); + } else if (window.matchMedia('(max-width: 2560px)').matches) { + setPageSize(15); + } + }; + if (alignment === 'card') { updatePageSize(); - window.addEventListener('resize', updatePageSize); } @@ -261,6 +260,10 @@ export default function ShowCluster() { setSeedPeerTotalPages(totalPage); setAllSeedPeers(currentPageData); + + return () => { + window.removeEventListener('resize', updatePageSize); + }; } else { setSeedPeerTotalPages(1); setAllSeedPeers([]); diff --git a/src/components/developer/tokens/index.tsx b/src/components/developer/tokens/index.tsx index 146e0304..14ca2e59 100644 --- a/src/components/developer/tokens/index.tsx +++ b/src/components/developer/tokens/index.tsx @@ -201,7 +201,7 @@ export default function PersonalAccessTokens() { { + window.removeEventListener('resize', updatePageSize); + }; } else if (cluster === null || cluster) { setTotalPages(1); setAllClusters([]); diff --git a/src/components/resource/persistent-cache-task/information/index.tsx b/src/components/resource/persistent-cache-task/information/index.tsx index bc4ec0d8..46cd6d2a 100644 --- a/src/components/resource/persistent-cache-task/information/index.tsx +++ b/src/components/resource/persistent-cache-task/information/index.tsx @@ -169,6 +169,10 @@ export default function Information(props: InformationProps) { setTotalPages(totalPage); setAllPersistentCacheTasks(currentPageData); setTaskIsLoading(true); + + return () => { + window.removeEventListener('resize', updatePageSize); + }; } else if (persistentCacheTasksCount === null || persistentCacheTasksCount) { setTotalPages(1); setAllPersistentCacheTasks([]);