From 500900d9c69b641bb9de2f558554a50d0054af34 Mon Sep 17 00:00:00 2001 From: Abdelrahman Awad Date: Sun, 16 Feb 2025 23:49:19 +0200 Subject: [PATCH] feat: disable the navigation if readonly --- packages/core/src/useCalendar/useCalendar.ts | 14 +++++++++++--- packages/playground/src/App.vue | 14 +++++++------- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/packages/core/src/useCalendar/useCalendar.ts b/packages/core/src/useCalendar/useCalendar.ts index a82e8936..43b4e72d 100644 --- a/packages/core/src/useCalendar/useCalendar.ts +++ b/packages/core/src/useCalendar/useCalendar.ts @@ -174,6 +174,10 @@ export function useCalendar(_props: Reactivify { + if (isDisabled.value || toValue(props.readonly)) { + return; + } + focusedDay.value = date; await nextTick(); focusCurrent(); @@ -198,6 +202,10 @@ export function useCalendar(_props: Reactivify ({ id: `${calendarId}-next`, 'aria-label': 'Next', - disabled: isDisabled.value, + disabled: isDisabled.value || toValue(props.readonly), onClick: () => { if (currentView.value.type === 'weeks') { context.setFocusedDate(context.getFocusedDate().add({ months: 1 })); @@ -289,7 +297,7 @@ export function useCalendar(_props: Reactivify ({ id: `${calendarId}-previous`, 'aria-label': 'Previous', - disabled: isDisabled.value, + disabled: isDisabled.value || toValue(props.readonly), onClick: () => { if (currentView.value.type === 'weeks') { context.setFocusedDate(context.getFocusedDate().subtract({ months: 1 })); @@ -322,7 +330,7 @@ export function useCalendar(_props: Reactivify { - if (isDisabled.value) { + if (isDisabled.value || toValue(props.readonly)) { return; } diff --git a/packages/playground/src/App.vue b/packages/playground/src/App.vue index 55b46e8f..8befe958 100644 --- a/packages/playground/src/App.vue +++ b/packages/playground/src/App.vue @@ -1,12 +1,12 @@