Skip to content

Commit 762628a

Browse files
authored
fix(frontend): prevent flash of empty seed opinion page during conver… (#411)
* fix(frontend): prevent flash of empty seed opinion page during conversation creation When clicking "Publier" to create a conversation with seed opinions, the page briefly flashed showing the empty seed opinion creation form before navigating to the final conversation page. Root cause: The NewConversationRouteGuard component checks for unsaved changes before allowing navigation. When the route was not unlocked, attempting to navigate triggered the route guard's "save draft" dialog or caused timing issues with the reactive store updates, leading to a flash of empty state. Changes: - Add ref to NewConversationRouteGuard to access its unlockRoute() method - Call unlockRoute() before router.replace() to bypass unsaved changes check - Remove draft clearing logic that was causing reactive store re-renders This ensures the component maintains its seed opinion data during navigation and transitions smoothly to the conversation page without intermediate UI flashes or save prompts. * chore: improve ai-assistant rules on commit
1 parent 904d428 commit 762628a

2 files changed

Lines changed: 14 additions & 7 deletions

File tree

CLAUDE.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,14 +98,19 @@ duplicate updates and database contention."
9898
```
9999

100100
**Guidelines:**
101-
- Keep the subject line concise (50-72 characters)
101+
- Keep the subject line under 50 characters (hard limit: 72 characters)
102+
- Git and GitHub truncate titles longer than ~72 characters with "..."
103+
- Aim for 50 characters to ensure full visibility in all tools
104+
- If the title is too long, move specific details to the body
105+
- Good: `fix(frontend): prevent seed opinion page flash`
106+
- Bad: `fix(frontend): prevent flash of empty seed opinion page during conversation creation`
102107
- Use imperative mood ("add" not "added" or "adds")
103108
- Don't capitalize the first letter after the colon
104109
- No period at the end of the subject line
105-
- **Be exhaustive in the body**: explain what changed, why it changed, and any important implementation details
110+
- Be exhaustive in the body: explain what changed, why it changed, and any important implementation details
106111
- Use the body to provide context that reviewers and future maintainers will need
107112
- Reference issue numbers, design decisions, or related PRs in the body or footer
108-
- **Do NOT mention AI assistants or tools in commit messages** (e.g., "Claude", "AI-generated", "with assistance from")
113+
- Do NOT mention AI assistants or tools in commit messages (e.g., "Claude", "AI-generated", "with assistance from")
109114
- This restriction applies ONLY to commit messages - code comments can mention tools/AI if helpful for context
110115

111116
**Before committing:**

services/agora/src/pages/conversation/new/review/index.vue

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@
9292
</div>
9393

9494
<NewConversationRouteGuard
95+
ref="routeGuard"
9596
:allowed-routes="['/conversation/new/create/', '/welcome/']"
9697
/>
9798

@@ -136,7 +137,7 @@ import { useNavigationStore } from "src/stores/navigation";
136137
const { isLoggedIn } = storeToRefs(useAuthenticationStore());
137138
const router = useRouter();
138139
139-
const { createEmptyDraft, validateForReview } = useNewPostDraftsStore();
140+
const { validateForReview } = useNewPostDraftsStore();
140141
const { conversationDraft } = storeToRefs(useNewPostDraftsStore());
141142
142143
const { createNewPost } = useBackendPostApi();
@@ -146,6 +147,7 @@ const { handleAxiosErrorStatusCodes } = useCommonApi();
146147
const showLoginDialog = ref(false);
147148
const isSubmitButtonLoading = ref(false);
148149
const currentActiveOpinionIndex = ref(-1);
150+
const routeGuard = ref<{ unlockRoute: () => void } | undefined>(undefined);
149151
150152
// Validation state
151153
const opinionErrors = ref<Record<number, string>>({});
@@ -341,14 +343,14 @@ async function onSubmit() {
341343
// Set navigation context to indicate user came from conversation creation
342344
navigationStore.setConversationCreationContext(true);
343345
346+
// Unlock route to prevent "save draft" dialog
347+
routeGuard.value?.unlockRoute();
348+
344349
await router.replace({
345350
name: "/conversation/[postSlugId]",
346351
params: { postSlugId: response.data.conversationSlugId },
347352
});
348353
349-
// Clear draft after navigation to prevent re-render with empty data
350-
conversationDraft.value = createEmptyDraft();
351-
352354
// Don't stop loading - let component unmount with loading state active
353355
} else {
354356
isSubmitButtonLoading.value = false;

0 commit comments

Comments
 (0)