diff options
| author | syuilo <Syuilotan@yahoo.co.jp> | 2023-03-03 11:43:53 +0900 |
|---|---|---|
| committer | syuilo <Syuilotan@yahoo.co.jp> | 2023-03-03 11:43:53 +0900 |
| commit | 3066a133ac339bfbc0c1707b3c8c7af10ea2d082 (patch) | |
| tree | 2028c3868b557ea034be8daa51e40acc8f95923a | |
| parent | New Crowdin updates (#10114) (diff) | |
| download | sharkey-3066a133ac339bfbc0c1707b3c8c7af10ea2d082.tar.gz sharkey-3066a133ac339bfbc0c1707b3c8c7af10ea2d082.tar.bz2 sharkey-3066a133ac339bfbc0c1707b3c8c7af10ea2d082.zip | |
fix(client): prevent null reference error
| -rw-r--r-- | packages/frontend/src/components/global/MkStickyContainer.vue | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/packages/frontend/src/components/global/MkStickyContainer.vue b/packages/frontend/src/components/global/MkStickyContainer.vue index 3f9c1bc353..44c02088da 100644 --- a/packages/frontend/src/components/global/MkStickyContainer.vue +++ b/packages/frontend/src/components/global/MkStickyContainer.vue @@ -32,11 +32,17 @@ const parentStickyBottom = inject<Ref<number>>(CURRENT_STICKY_BOTTOM, ref(0)); provide(CURRENT_STICKY_BOTTOM, $$(childStickyBottom)); const calc = () => { - childStickyTop = parentStickyTop.value + headerEl.offsetHeight; - headerHeight = headerEl.offsetHeight.toString(); + // コンポーネントが表示されてないけどKeepAliveで残ってる場合などは null になる + if (headerEl != null) { + childStickyTop = parentStickyTop.value + headerEl.offsetHeight; + headerHeight = headerEl.offsetHeight.toString(); + } - childStickyBottom = parentStickyBottom.value + footerEl.offsetHeight; - footerHeight = footerEl.offsetHeight.toString(); + // コンポーネントが表示されてないけどKeepAliveで残ってる場合などは null になる + if (footerEl != null) { + childStickyBottom = parentStickyBottom.value + footerEl.offsetHeight; + footerHeight = footerEl.offsetHeight.toString(); + } }; const observer = new ResizeObserver(() => { |