From 94ab71628261cd310abd786df5c7217c2fccabcd Mon Sep 17 00:00:00 2001 From: Yasutake Yohei <61961825+yasutakeyohei@users.noreply.github.com> Date: Fri, 20 Nov 2026 14:40:42 +0900 Subject: ScheduleInteractive.astro: カテゴリ変更時に選択日を移動しない MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 絞り込みで選択中の日付に該当がなくても、当月先頭の日付へ自動で移らないようにする - 該当がない日は「この日の予定はありません。」と表示する - 未使用になった ensureVisibleSelection を削除 --- src/components/ScheduleInteractive.astro | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) (limited to 'src') diff --git a/src/components/ScheduleInteractive.astro b/src/components/ScheduleInteractive.astro index e409475..b7c8481 100644 --- a/src/components/ScheduleInteractive.astro +++ b/src/components/ScheduleInteractive.astro @@ -163,20 +163,6 @@ return list.filter(matchesCategory); } - function ensureVisibleSelection() { - if (selectedDate && visibleEntries(selectedDate).length > 0) return; - // 絞り込みで選択中の日付が空になったら、当月の最初の該当日へ移動する。 - // 当月に該当日がなければ、最初の該当日へ移動する。 - const inMonth = dateKeys.filter( - (k) => k.startsWith(currentMonth) && visibleEntries(k).length > 0 - ); - const any = dateKeys.filter((k) => visibleEntries(k).length > 0); - const fallback = inMonth[0] || any[0]; - if (!fallback) return; - selectedDate = fallback; - currentMonth = fallback.slice(0, 7); - } - function renderCalendar() { const index = months.indexOf(currentMonth); const [year, month] = currentMonth.split('-').map(Number); @@ -492,7 +478,7 @@ b.setAttribute('aria-pressed', String(b.dataset.category === activeCategory)); }); applyFilter(); - ensureVisibleSelection(); + // カテゴリを変えても、選択中の日付は動かさない(その日に該当がなければ「予定はありません」と出す)。 renderCalendar(); if (selectedDate) showDayDetails(selectedDate); } -- cgit v1.3.1