Skip to content

Commit af31b27

Browse files
fix(dotcom): navigate away from file when leaving its group (tldraw#8930)
In order to avoid leaving the user stuck on a file they no longer have access to, this PR makes `handleLeaveGroup` mirror `handleDeleteGroup` in `GroupSettingsDialog`: if the user is viewing a file owned by the group they just left, navigate them to `/`. Previously the sidebar updated but the file stayed open until the next server-side access check failed with `FORBIDDEN`. Closes tldraw#8340 ### Change type - [x] `bugfix` ### Test plan 1. Be a member of a group that owns files. 2. Open a file belonging to that group. 3. Open group settings and leave the group. 4. You should be redirected away from the file instead of remaining on it. ### Release notes - Fix: redirect away from a group file when leaving the group.
1 parent c437b2e commit af31b27

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

apps/dotcom/client/src/tla/components/dialogs/GroupSettingsDialog.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,13 @@ export function GroupSettingsDialog({ groupId, onClose }: GroupSettingsDialogPro
104104

105105
const handleLeaveGroup = async () => {
106106
try {
107+
const isCurrentlyOnAFileInThisGroup =
108+
currentFileId && app.getFile(currentFileId)?.owningGroupId === groupId
107109
await app.z.mutate.leaveGroup({ groupId }).client
108110
onClose()
111+
if (isCurrentlyOnAFileInThisGroup) {
112+
navigate('/')
113+
}
109114
} catch (error) {
110115
console.error('Error leaving group:', error)
111116
}

0 commit comments

Comments
 (0)