denoland / fresh

The next-gen web framework.
https://fresh.deno.dev
MIT License
12.24k stars 626 forks source link

f-partial does nothing #2544

Closed finalclass closed 3 months ago

finalclass commented 3 months ago

I've created a brand new project (the way described in the docs). Then I've added two files:

routes/test/index.tsx

import { Partial } from "$fresh/runtime.ts";

export default function Test() {
  return (
    <div>
      TEEEEEEEEEEE
      <a href="" f-partial="/partials/test">GO</a>

      <Partial name="CartProducts">
        ???
      </Partial>
    </div>
  );
}

routes/partials/test.tsx

import { Partial } from "$fresh/runtime.ts";

export default function Test() {
  return (
    <Partial name="CartProducts">
      DONE
    </Partial>
  );
}

After visiting the /test route and clicking the "GO" button the page refreshes instead of loading the partial.

marvinhagemeister commented 3 months ago

Partials only become active if the element you clicked on or one of its ancestors has f-client-nav attribute set. If that is not set or it's set to false, then partials are disabled. See https://fresh.deno.dev/docs/concepts/partials

Wondering if we should enable this by default when f-partial is set. That might be less confusing.

finalclass commented 3 months ago

Thanks for clarifying. Maybe adding a full code example here would be clearer:

image