Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 3 additions & 1 deletion examples/notes/src/components/EditButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@
*
*/
import type { JSX } from "@solidjs/web";
import { useSearchLink } from "~/lib/links";

export default function EditButton(props: { noteId?: number; children: JSX.Element }) {
const searchLink = useSearchLink();
const isDraft = !("noteId" in props);
return (
<a
href={!isDraft ? `/notes/${props.noteId}/edit` : `/new`}
href={searchLink(!isDraft ? `/notes/${props.noteId}/edit` : `/new`)}
class={["edit-button", isDraft ? "edit-button--solid" : "edit-button--outline"].join(" ")}
role="menuitem"
>
Expand Down
4 changes: 3 additions & 1 deletion examples/notes/src/components/SidebarNoteContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import { useLocation } from "@solidjs/router";
import { createEffect, createSignal, Show } from "solid-js";
import type { JSX } from "@solidjs/web";
import { useSearchLink } from "~/lib/links";

export default function SidebarNoteContent(props: {
id: number;
Expand All @@ -22,6 +23,7 @@ export default function SidebarNoteContent(props: {
expandedChildren: JSX.Element;
}) {
const location = useLocation();
const searchLink = useSearchLink();
const [isExpanded, setIsExpanded] = createSignal(false);
const isActive = () => location.pathname.startsWith(`/notes/${props.id}`);
let itemRef!: HTMLDivElement;
Expand All @@ -48,7 +50,7 @@ export default function SidebarNoteContent(props: {
>
{props.children}
<a
href={`/notes/${props.id}`}
href={searchLink(`/notes/${props.id}`)}
class="sidebar-note-open"
style={{
"background-color": isActive() ? "var(--tertiary-blue)" : "",
Expand Down
14 changes: 14 additions & 0 deletions examples/notes/src/lib/links.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// The sidebar filter IS the `?searchText` query param — the root preload reads
// it, so the notes-list server component refetches whenever it changes. That
// makes it navigation state, not component state: a link that drops it clears
// the search box and refetches the unfiltered list the moment you click a
// note. Every in-app link therefore carries the current filter forward.
import { useLocation } from "@solidjs/router";

export function useSearchLink() {
const location = useLocation();
return (path: string) => {
const searchText = location.query.searchText;
return searchText ? `${path}?searchText=${encodeURIComponent(String(searchText))}` : path;
};
}
6 changes: 6 additions & 0 deletions packages/solid-web/frames/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,12 @@ function claimRender(prefix: string, existing: Node[], render: () => any) {
const prevRegistry = sc.registry;
const prevHydrating = sc.hydrating;
const prevClaimRoots = sc.claimRoots;
// The enclosing pass gathered these same nodes: gatherHydratable sweeps the
// whole document for `_hk`, frame regions included, so every slot root ends
// up in the root registry too. Only this scoped registry ever claims them,
// so hand ownership over — otherwise the root's completion check reports
// each claimed slot node as unclaimed server markup.
if (prevRegistry) for (const key of registry.keys()) prevRegistry.delete(key);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

maybe this is a bad fix

sc.registry = registry;
sc.hydrating = true;
// The range may be DETACHED right now (an async slot fill renders before
Expand Down
Loading