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

Fixed elements are only rendered in preview frame if Page is published #2151

Closed
robinboening opened this issue Jul 5, 2021 · 4 comments
Closed

Comments

@robinboening
Copy link
Contributor

Steps to reproduce

  1. set up and create a fixed element on a page
  2. see it does not render in the preview frame
  3. publish the Page
  4. see the element appearing in the preview frame

Expected behavior

The fixed element should be rendered in the preview frame right after its creation.

Actual behavior

After creating the fixed element it does not render in the preview frame. The Page needs to be published before it appears.

System configuration

  • Alchemy Version: main
  • Rails Version: 6
@robinboening
Copy link
Contributor Author

Just as a side note: Tis is not related to the big Ingredient restructuring because I've noticed this behaviour before #2061 was merged.

@robinboening
Copy link
Contributor Author

robinboening commented Aug 6, 2021

I just found the reason for this behaviour. The docs suggest to render fixed elements based on @page. @page is not the draft version though, hence the need to publish before actually seeing the element in the preview.

At the moment I am not sure what the best solution is.

@robinboening
Copy link
Contributor Author

robinboening commented Aug 6, 2021

Currently, the render_elements helper is the piece to ensure pulling elements from @page.draft_version in preview mode.
To me it seems like this distinction is currently made on a level too high, but I might not see potential side-effects if we move this down to a lower level, like the controller.

A wild idea to always deal with the draft version in the preview

class Alchemy::Admin::PagesController < ResourcesController
  def load_resource
    @page = PageVersion.eager_load(page: :language).find_by(page_id: params[:id])
  end
end

This definitely breaks a lot of thinks and I can not imagine the impact, but it doesn't feel wrong to me.

@tvdeyen what are your thoughts (not only on this idea, but in general)?

@robinboening
Copy link
Contributor Author

After a quick discussion with @tvdeyen he pointed me to use render_elements fixed: true. It is intentional that @page is always the published version.

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

No branches or pull requests

1 participant