Skip to content
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions src/runtime/composables/useResizable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,12 @@ export function useResizable(key: string, options: Ref<UseResizableProps> | UseR
: useStorage<StorageType>(key, defaultStorageValue, undefined, opts.value.storageOptions)
: ref(defaultStorageValue)

if (storageData.value == null || typeof storageData.value !== 'object') {
storageData.value = { ...defaultStorageValue }
}

const isCollapsed = computed({
get: () => storageData.value.collapsed,
get: () => storageData.value?.collapsed ?? defaultStorageValue.collapsed,
set: (value: boolean) => {
if (!opts.value.collapsible) {
return
Expand All @@ -133,7 +137,7 @@ export function useResizable(key: string, options: Ref<UseResizableProps> | UseR
const previousSize = ref(opts.value.defaultSize)

const size = computed({
get: () => storageData.value.size,
get: () => storageData.value?.size ?? defaultStorageValue.size,
set: (value) => { storageData.value.size = value }
})

Expand Down Expand Up @@ -328,7 +332,7 @@ export function useResizable(key: string, options: Ref<UseResizableProps> | UseR
}

// Initial sync of storage value to external collapsed ref
if (isRef(collapsed) && storageData.value.collapsed) {
if (isRef(collapsed) && storageData.value?.collapsed) {
collapsed.value = storageData.value.collapsed
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟑 Minor | ⚑ Quick win

Initial sync should not ignore persisted false

The condition only syncs when persisted collapsed is truthy, so an explicit persisted false is skipped and can leave the external ref out of sync.

Suggested fix
-  if (isRef(collapsed) && storageData.value?.collapsed) {
+  if (isRef(collapsed) && typeof storageData.value?.collapsed === 'boolean') {
     collapsed.value = storageData.value.collapsed
   }
πŸ€– Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/runtime/composables/useResizable.ts` around lines 335 - 337, The sync
currently skips persisted false because it checks truthiness; update the
condition that sets collapsed.value so it detects an explicit stored false (e.g.
check for undefined rather than falsiness). Locate the block using
isRef(collapsed) and storageData.value?.collapsed and change the guard to verify
storageData.value exists and storageData.value.collapsed is not undefined (or
use `'collapsed' in storageData.value`) before assigning collapsed.value =
storageData.value.collapsed.


Expand All @@ -339,8 +343,12 @@ export function useResizable(key: string, options: Ref<UseResizableProps> | UseR
return
}

if (storageData.value.collapsed !== value) {
storageData.value.collapsed = value
if (storageData.value?.collapsed !== value) {
if (storageData.value == null || typeof storageData.value !== 'object') {
storageData.value = { ...defaultStorageValue, collapsed: value }
} else {
storageData.value.collapsed = value
}
}
})
}
Expand Down
Loading