You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Remove dependency on ActionView::Base, eliminating the need for capture compatibility patch. (#2287)
* Remove dependency on ActionView::Base, eliminating the need for capture compatibility patch.
Co-authored-by: Cameron Dutro <camertron@gmail.com>
* Use later version of Rails 7.1 for PVC integration tests
* docs updates
---------
Co-authored-by: Cameron Dutro <camertron@gmail.com>
Copy file name to clipboardExpand all lines: docs/known_issues.md
-40Lines changed: 0 additions & 40 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -27,46 +27,6 @@ en:
27
27
28
28
It would be lovely if we could support rendering ViewComponents in Jekyll, as it would enable the reuse of ViewComponents across static and dynamic (Rails-based) sites.
29
29
30
-
## Issues resolved by the optional capture compatibility patch
31
-
32
-
If you're experiencing issues with duplicated content or malformed HTML output (such as using `concat` in a helper), the capture compatibility patch may resolve these.
33
-
34
-
[Set `config.view_component.capture_compatibility_patch_enabled` to `true`](https://viewcomponent.org/api.html#capture_compatibility_patch_enabled) to resolve these issues.
35
-
36
-
These issues arise because the related features/methods keep a reference to the
37
-
primary `ActionView::Base` instance, which has its own `@output_buffer`. When
38
-
`#capture`is called on the original `ActionView::Base` instance while
39
-
evaluating a block from a ViewComponent, the `@output_buffer` is overridden in
40
-
the `ActionView::Base` instance, and *not* the component. This results in a
41
-
double render due to `#capture` implementation details.
42
-
43
-
To resolve the issue, we override `#capture` so that we can delegate the
44
-
`capture`logic to the ViewComponent that created the block.
45
-
46
-
### turbo_frame_tag double rendering or scrambled HTML structure
47
-
48
-
When using `turbo_frame_tag` inside a ViewComponent, the template may be rendered twice. See [https://github.com/github/view_component/issues/1099](https://github.com/github/view_component/issues/1099).
49
-
50
-
As a workaround, use `tag.turbo_frame` instead of `turbo_frame_tag`.
51
-
52
-
Note: For the same functionality as `turbo_frame_tag(my_model)`, use `tag.turbo_frame(id: dom_id(my_model))`.
53
-
54
-
### Compatibility with Rails form helpers
55
-
56
-
ViewComponent [isn't compatible](https://github.com/viewcomponent/view_component/issues/241) with `form_for` helpers by default.
57
-
58
-
Passing a form object (often `f`) to a ViewComponent works for simple cases like `f.text_field :name`. Content may be ill-ordered or duplicated in complex cases, such as passing blocks to form helpers or when nesting components.
59
-
60
-
Some workarounds include:
61
-
62
-
- Experimental: Enable the capture compatibility patch with `config.view_component.capture_compatibility_patch_enabled = true`.
63
-
- Render an entire form within a single ViewComponent.
64
-
- Render a [partial](https://guides.rubyonrails.org/layouts_and_rendering.html#using-partials) within the ViewComponent which includes the form.
65
-
- Use a [custom `FormBuilder`](https://guides.rubyonrails.org/form_helpers.html#customizing-form-builders) to create reusable form components:
66
-
- Using FormBuilder with [Action View helpers](https://api.rubyonrails.org/classes/ActionView/Helpers/FormBuilder.html).
67
-
- Using a FormBuilder overriding all field helpers to render a ViewComponent so each field can be customized individually (for example, [view_component-form](https://github.com/pantographe/view_component-form)).
68
-
- Using a lightweight re-implementation of ViewComponent. For example, [Primer ViewComponents](https://github.com/primer/view_components) implemented [`ActsAsComponent`](https://github.com/primer/view_components/blob/main/lib/primer/forms/acts_as_component.rb) which is used in the context of `FormBuilder`.
69
-
70
30
## Forms don't use the default `FormBuilder`
71
31
72
32
Calls to form helpers such as `form_with` in ViewComponents [don't use the default form builder](https://github.com/viewcomponent/view_component/pull/1090#issue-753331927). This is by design, as it allows global state to change the rendered output of a component. Instead, consider passing a form builder into form helpers via the `builder` argument:
0 commit comments