ash-project / ash_hq

The Ash Framework homepage and documentation site.
MIT License
48 stars 26 forks source link

Incorrect headings when navigating between particular pages #38

Closed mbuhot closed 1 year ago

mbuhot commented 1 year ago

Brief Description

Navigating from https://ash-hq.org/docs/guides/ash_postgres/1.1.1/topics/polymorphic_resources.md to https://ash-hq.org/docs/guides/ash_postgres/1.1.1/topics/migrations_and_tasks.md via the tree-view results in the "Migrations" heading appears both as a <h1> and as a <h2> (see image).

Steps to reproduce the bug

On MacOS Safari visit https://ash-hq.org/docs/guides/ash_postgres/1.1.1/topics/polymorphic_resources.md Click the Guides -> Topics -> Ash Postgres -> Migrations and Tasks link in the tree view Notice the header is incorrect. Refresh the page and it displays correctly.

Context

image

Perhaps it is related to both pages having a DOM element with id="migrations" ?

mbuhot commented 1 year ago

Looks like this is actually a bug in morphdom: https://github.com/patrick-steele-idem/morphdom/pull/231

I'll see if there's a workaround without the performance hit of replacing <LivePatch> with <LiveRedirect>

zachdaniel commented 1 year ago

Wow, great digging! If we have to use <LiveRedirect> it won't be horrible, but definitely worth looking for a different workaround. We could potentially prefix the ids with some unique string when building the markdown html?

mbuhot commented 1 year ago

Yes unique IDs will solve it. We could generate a unique prefix based on a hash of the page title/content or even just the heading level, so that we'd have h1-migrations and h2-migrations.

zachdaniel commented 1 year ago

Every version of everything has a uuid, so we should be able to just use that as a prefix when generating the HTML.

zachdaniel commented 1 year ago

If we thread through the UUID of the thing we're rendering all the way down to here: https://github.com/ash-project/ash_hq/blob/main/lib/ash_hq/docs/extensions/render_markdown/render_markdown.ex#L115, then we can prefix all the ids with that.

mbuhot commented 1 year ago

Thanks @zachdaniel, I'll create a PR today 👍