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

Add support to replace the turbo_frame contents #145

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

hajee
Copy link

@hajee hajee commented Jul 25, 2024

We've identified an area for improvement in the current turbo-frame command handling.

Current Behaviour

Currently when a command is initiated within a turbo-frame and no turbo stream is available, the entire HTML is recreated on the server and sent back to the client. The client then utilized the Append strategy, appending the content to the current document.

Difference between Command and TurboLinks behavior

In contrast, clicking a link within a turbo frame only replaces the contents of the frame with the corresponding frame content from the returned HTML. You can read more about this behavior here.

Benefits of the Turbo Links Behavior

The turbo links behavior is particularly beneficial in scenarios where the controller and the HTML contain extensive logic. Implementing parts of this logic within turbo streams can be cumbersome, requiring significant effort and increasing maintenance overhead. By adopting the FrameReplace strategy, we alleviate the need to replicate complex logic in turbo streams, simplifying the development process and reducing potential maintenance challenges.

To enhance consistency and improve user experience, we've introduced a new strategy called FrameReplace in this PR. This strategy morphs the current content of the turbo frame with the returned content of the turbo frame, mimicking the behavior of turbo links.

Key Points of the FrameReplace Strategy:

  • Selective Activation: The FrameReplace strategy is activated only when there is no turbo stream available for the current action, ensuring backward compatibility.
  • Enhanced Consistency: Commands within turbo frames now behave similarly to turbo links, providing a more intuitive and seamless user experience.

We believe this update will significantly enhance the functionality and user experience of turbo frames.

@hajee
Copy link
Author

hajee commented Aug 2, 2024

Hi Nate,

I know it is holiday season and you are either on vacation or busy. But do you have an expected time frame for when you can take a look at the idea behind the PR and see if this is the way you want to go with this?

@hopsoft
Copy link
Owner

hopsoft commented Oct 17, 2024

Turning my attention back to this soon. Thanks for being patient. 🙏🏻

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

Successfully merging this pull request may close these issues.

2 participants