Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Element IDs change from preview to published content #2354

Closed
Fritzti opened this issue Jun 28, 2022 · 3 comments
Closed

Element IDs change from preview to published content #2354

Fritzti opened this issue Jun 28, 2022 · 3 comments

Comments

@Fritzti
Copy link

Fritzti commented Jun 28, 2022

Steps to reproduce

  • add element with link .
  • add target elem.
  • set anchor to target elem id on same site.

Expected behavior

anchor linked id is same than target id in published page dom.

Actual behavior

anchor link id differs from target id in published page dom.

System configuration

  • Alchemy Version:
  • 6.0.8
  • Rails Version:
    -7.0.3
@Fritzti Fritzti changed the title Element IDs change from preview to published content destroying anchors in side navigation Element IDs change from preview to published content, destroying anchors in side navigation Jun 28, 2022
@Fritzti Fritzti changed the title Element IDs change from preview to published content, destroying anchors in side navigation Element IDs change from preview to published content Jun 28, 2022
@tvdeyen
Copy link
Member

tvdeyen commented Jul 25, 2022

That's true and due to the nature that we copy elements from the draft to the published page version. The only way I think we can solve this is by not using the database id for the DOM ID.
We could use the content of the preview_content, but we would need to make sure that the ID is still unique on that page.
Any ideas?

@tvdeyen
Copy link
Member

tvdeyen commented Sep 2, 2022

After considering, I think the best way forward is to not implicitly add DOM ids in Alchemy helpers. Whoever needs DOM ids for their elements should implement their own logic. Polluting the DOM with ids for every element we render has never been a good idea. That's why in #2368 we are deprecating this behavior.

tvdeyen added a commit to tvdeyen/alchemy_cms that referenced this issue Sep 3, 2022
We cannot use the id, because that will change if publish the page.
The position will be the same across versions and combined with
the name it is unique on each page.

Fixes AlchemyCMS#2354
tvdeyen added a commit to tvdeyen/alchemy_cms that referenced this issue Sep 4, 2022
We cannot use the id, because that will change if publish the page.
The position will be the same across versions and combined with
the name it is unique on each page.

Fixes AlchemyCMS#2354
@tvdeyen
Copy link
Member

tvdeyen commented Sep 4, 2022

@Fritzti with the work in #2368 (will be released in 6.0) and #2373 (will be released in 6.1) it should be possible to fix the issue.

@tvdeyen tvdeyen closed this as completed in 2d9f213 Sep 4, 2022
tvdeyen added a commit that referenced this issue Sep 4, 2022
We cannot use the id, because that will change if publish the page.
The position will be the same across versions and combined with
the name it is unique on each page.

Fixes #2354
@tvdeyen tvdeyen mentioned this issue Sep 7, 2022
3 tasks
dbwinger pushed a commit to dbwinger/alchemy_cms that referenced this issue Mar 20, 2023
We cannot use the id, because that will change if publish the page.
The position will be the same across versions and combined with
the name it is unique on each page.

Fixes AlchemyCMS#2354
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants