no-navigation-without-resolve does not allow fragment only
#1537
no-navigation-without-resolve does not allow fragment onlyDevelopment PRs
What does this PR do?
This PR fixes two related issues in the compliance course flow:
• Teachers can now create compliance courses even if they haven't set a certificate deadline yet. • Previously, courses without a certificate deadline would prevent students from enrolling (showing errors or blocking enrollment entirely). • Additionally, fixed an infinite error loop that was appearing on the course enrollment page in some cases.
These changes make compliance course creation more flexible while ensuring enrollment works reliably.
Type of change
- Bug fix (non-breaking change which fixes an issue)
- Chore (refactoring code, technical debt, workflow improvements)
- Enhancement (small improvements)
- New feature (non-breaking change which adds functionality)
- Breaking change (fix or feature that would cause existing functionality to not work as expected)
- This change adds a new database migration
- This change requires a documentation update
How should this be tested?
Create a new Compliance course as a teacher. Try saving/publishing the course without setting a certificate deadline. Verify that the course can be published successfully. As a student, attempt to enroll in that course — it should work without errors. Test the course enrollment page to ensure no infinite error loops appear.
Checklist
Required
- Filled out the "How to test" section in this PR
- Self-reviewed my own code
- Commented on my code in hard-to-understand bits
- Ran
pnpm build - Checked for warnings, there are none
- Removed all
console.logs - Merged the latest changes from main onto my branch with
git pull origin main - My changes don't cause any responsiveness issues
Appreciated
- If a UI change was made: Added a screen recording or screenshots to this PR
- Updated the ClassroomIO Docs if changes were necessary
Summary by CodeRabbit
-
New Features
- Added guided navigation that highlights relevant settings and controls.
- Added certificate deadline validation for downloadable certificates and compliance course publishing.
- Added prompts directing users to certificate settings when a deadline is required.
- Added clearer enrollment error messages.
- Added URL-based tab selection and highlighting for certificate settings.
- Added reactive AI tutor settings loading when switching organizations.
-
Bug Fixes
- Improved handling of AI tutor settings loading errors.
- Prevented issues when reordering questions containing missing data.
Greptile Summary
This PR fixes compliance course creation and enrollment: teachers can now publish a compliance course without a certificate deadline (a dialog gates publishing and redirects to certificate settings), and an infinite auto-enrollment loop on the enroll page is resolved. It also introduces a reusable AttentionHighlight component and goAndHighlight routing utility for URL-driven scroll-and-pulse UX across several settings pages.
- Compliance publish gate:
onPublishToggleinsettings.svelteintercepts publishing of compliance courses with no certificate deadline, showing a dialog that navigates teachers to certificate settings with the deadline field highlighted. - Enrollment loop fix:
enrollmentErroris added to the$effectguard inenroll/+page.svelte, stopping infinite re-triggers on failure; acatchblock and in-page error render ensure users always see failure feedback. - AttentionHighlight / goAndHighlight: New shared components provide typed, URL-based scroll-and-highlight navigation replacing the old hash-based approach; org-settings now re-initializes reactively on org change.
Confidence Score: 4/5
Safe to merge with the tab snap-back fixed; the enrollment loop and compliance publish gating changes are solid.
The tab snap-back in certificate-edit.svelte is a present behavioral defect: the $effect reading page.url re-fires when AttentionHighlight's replaceState cleans up the ?highlight param, overriding any manual tab change the user made during the 3-second pulse window. Everything else — the enrollment loop fix, the compliance publish dialog, AttentionHighlight, and goAndHighlight — looks correct and well-structured.
Files Needing Attention: apps/dashboard/src/lib/features/course/components/ceritficate/certificate-edit.svelte — the $effect for URL-based tab initialization needs a run-once guard.
Important Files Changed
| Filename | Overview |
|---|---|
| apps/dashboard/src/lib/features/course/components/ceritficate/certificate-edit.svelte | Switches activeTab from a bindable prop to URL-derived local state; the reactive $effect re-fires on every page.url change (including the highlight cleanup replaceState), snapping the tab back to settings if the user navigated away during the pulse window. |
| apps/dashboard/src/lib/features/ui/attention-highlight.svelte | New component that pulses/scrolls a wrapped element when the URL's ?highlight or #hash matches its id, then cleans up the URL param via replaceState after a configurable duration. |
| apps/dashboard/src/lib/routing/go-and-highlight.ts | New utility that builds a typed route URL with a ?highlight query param and calls goto(). Path tokens are encoded, extra keys become query params. |
| apps/dashboard/src/lib/routing/routes.ts | New typed routing constants: ROUTE_NAME enum, ROUTE_PATHS, ROUTE_SECTIONS, and utility types. |
| apps/dashboard/src/lib/features/course/pages/settings.svelte | Adds onPublishToggle that intercepts compliance course publishing when no certificate deadline is set, showing a dialog that navigates to certificate settings via goAndHighlight. |
| apps/dashboard/src/lib/features/course/components/ceritficate/certificate-settings.svelte | Adds derived certificateValidationErrors and wraps cert-deadline and cert-threshold fields in AttentionHighlight. The deadline_required message renders in two places simultaneously. |
| apps/dashboard/src/routes/(org-site)/course/[slug]/enroll/+page.svelte | Fixes the infinite auto-enrollment loop by adding enrollmentError to the $effect guard; adds a catch block with user-facing error display and snackbar notification. |
| apps/dashboard/src/lib/features/course/api/course.svelte.ts | Adds a specific handler for VALIDATION_ERROR/certificate.deadline responses during enrollment, showing a targeted snackbar. |
| apps/dashboard/src/lib/features/ai-tutor-settings/pages/org-settings.svelte | Migrates initialization from onMount to a $effect that re-runs when currentOrg changes. |
| apps/dashboard/src/lib/features/ai-tutor-settings/api/ai-tutor.svelte.ts | Adds onError handler to fetchOrgSettings that clears orgSettings and shows a snackbar; returns fetched settings for callers. |
| apps/dashboard/src/lib/features/ai-tutor-settings/pages/course-settings.svelte | Wraps inheritance and tutor-settings fields in AttentionHighlight for URL-based scroll-and-highlight navigation. |
| apps/dashboard/src/lib/features/course/components/course-context-menu-content.svelte | Replaces manual hash-redirect publish navigation with goAndHighlight. |
| apps/dashboard/src/lib/features/course/components/exercise/store.ts | Adds optional chaining on question properties inside the type guard filter, preventing crashes on undefined map entries. |
| apps/dashboard/src/lib/utils/translations/en.json | Adds deadline_required, deadline_required_enroll, and certificate settings strings in correct English. |
| apps/dashboard/src/lib/features/ui/index.ts | Exports the new AttentionHighlight component from the UI feature barrel. |
| apps/dashboard/src/routes/(app)/org/[slug]/setup/+page.svelte | Updates the publish course setup step to use goAndHighlight. |
Reviews (11): Last reviewed commit: "Merge branch 'main' into Course-creation..." | Re-trigger Greptile
Continuation of #1482 (originally #1444), rebased onto current main, with the review feedback from #1482 addressed.
What this does
svelte/no-navigation-without-resolve no longer reports:
- Resolved URLs followed by a query string or a fragment, e.g.
resolve('/foo') + '?page=2',`${resolve('/foo')}#section`,resolve('/') + (searchParams.size ? `?${searchParams}` : ''), or<a href="{resolve('/foo')}?page=2">. A URL counts as resolved if it starts withresolve()/asset()or aResolvedPathnamevalue. - Query-only and fragment-only URLs, e.g.
goto('?page=2'),<a href="?{searchParams}">orreplaceState('#top', {}), as they keep the current path. Fragment-only URLs were previously only allowed in links.
A resolved value followed by anything other than a query or a fragment (e.g. resolve('/foo') + '/bar') is still reported, since it bypasses the route type-checking of resolve(). This follows the discussion in sveltejs/kit#14750.
URLs may be built with + concatenation, template literals, multi-part href attributes, variables, array elements, object properties, {#each} items and ternaries, in any combination.
Behaviour change for href attributes
Previously, only the first part of a multi-part href attribute was checked, so <a href="{resolve('/foo')}/bar"> was not reported. All parts are now checked, so it is reported. To fix such links, pass the whole path to resolve() (e.g. resolve('/blog/[slug]', { slug })) and start a query or fragment with a literal ? or # (e.g. href="{resolve('/search')}?{params}").
Leading and trailing whitespace in an href is ignored, as browsers strip it, so <a href=" {resolve('/foo')} "> is not reported. Whitespace between the parts is kept, as it stays in the URL.
Review feedback from #1482
- Fixed a crash on template literals containing only
resolve()(or nothing). - Concatenation is only recognised for the
+operator. - Replaced the separate
BinaryExpression/TemplateLiteralhandling with a single check over the URL's parts. Variables, member accesses and{#each}items are expanded along the way. Cyclic definitions are guarded by a set of the variables expanded on the current path, rather than aFindVariableContext, because a shared one would make the branches of a ternary interfere with each other, and a fresh one per branch loops forever on cyclic definitions. - Documented queries, fragments and
ResolvedPathnamein the rule docs.
Related: #1381 adds suffix support behind an option; this PR enables it by default.
Issue
Before You File a Bug Report Please Confirm You Have Done The Following...
- I have tried restarting my IDE and the issue persists.
- I have updated to the latest version of the packages.
What version of ESLint are you using?
10.4.0
What version of eslint-plugin-svelte are you using?
3.17.1
What did you do?
import { replaceState } from '$app/navigation';
...
replaceState(`#hash`, {}); // Unexpected replaceState() call without resolve(). (eslint svelte/no-navigation-without-resolve)
What did you expect to happen?
No lint error
What actually happened?
Unexpected replaceState() call without resolve(). (eslint svelte/no-navigation-without-resolve)
Link to GitHub Repo with Minimal Reproducible Example
Will provide later if needed.
Additional comments
No response
This issue is is stale because it missing information and has been open for 60 days with no activity.
This issue has been automatically closed because we haven't received a response from the original author 🙈. This automation helps keep the issue tracker clean from issues that aren't actionable. Please reach out if you have more information for us! 🙂