Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

fix: sync Bucket state when bucket public/private setting changes (#49891)

Monica Khoury47fbf26e4b8d
diff --git a/apps/studio/state/storage-explorer.tsx b/apps/studio/state/storage-explorer.tsx
index d4fd8a84691..a2c7b089308 100644
--- a/apps/studio/state/storage-explorer.tsx
+++ b/apps/studio/state/storage-explorer.tsx
@@ -1899,6 +1899,16 @@ export const StorageExplorerStateContextProvider = ({ children }: PropsWithChild
bucket,
])
+ // [Monica] The effect above only refreshes `selectedBucket` when the project changes, so
+ // editing the current bucket (e.g. toggling public/private) doesn't update it there. This
+ // keeps `selectedBucket` synced to the bucket query on every change, so Get URL always
+ // uses the current public/private state instead of a stale one from initial load.
+ useEffect(() => {
+ if (bucket && state.projectRef === project?.ref) {
+ state.selectedBucket = bucket
+ }
+ }, [bucket, project?.ref, state.projectRef])
+
return (
<StorageExplorerStateContext.Provider value={state}>
{children}