Skip to content

[Admin] Fix Unclosed form_tag in table component#6172

Merged
tvdeyen merged 1 commit intosolidusio:mainfrom
swamp09:fix_unclosed_form_tag_in_admin_table_component
Mar 6, 2025
Merged

[Admin] Fix Unclosed form_tag in table component#6172
tvdeyen merged 1 commit intosolidusio:mainfrom
swamp09:fix_unclosed_form_tag_in_admin_table_component

Conversation

@swamp09
Copy link
Copy Markdown
Contributor

@swamp09 swamp09 commented Mar 3, 2025

Summary

This PR fixes an HTML structure break caused by an unclosed form_tag, ensuring that forms added after using ui/table are rendered correctly.

Background

While customizing the index page to add a new form, I encountered a problem where the added form was not displayed in the browser. Upon investigation, I discovered that the issue stemmed from the form_tag in ui/table/component.html.erb not being explicitly closed, which resulted in subsequent form tags disappearing.

<%= render component("ui/table/toolbar").new("data-#{stimulus_id}-target": "batchToolbar", role: "toolbar", "aria-label": t(".batch_actions"), hidden: true) do %>
  <%= form_tag '', id: batch_actions_form_id %>
  <% @data.batch_actions.each do |batch_action| %>
    <%= render_batch_action_button(batch_action) %>
  <% end %>
<% end %>

Due to the lack of a proper block structure closing the form_tag, the HTML became malformed, and any form tags declared afterward were not rendered.

Updated the form_tag to use a block form, ensuring that the opening and closing tags are explicitly defined.

Checklist

Check out our PR guidelines for more details.

The following are mandatory for all PRs:

The following are not always needed:

  • 📖 I have updated the README to account for my changes.
  • 📑 I have documented new code with YARD.
  • 🛣️ I have opened a PR to update the guides.
  • ✅ I have added automated tests to cover my changes.
  • 📸 I have attached screenshots to demo visual changes.

This PR fixes an HTML structure break caused by an unclosed form_tag, ensuring that forms added after using ui/table are rendered correctly.

## Background

While customizing the index page to add a new form, I encountered a problem where the added form was not displayed in the browser. Upon investigation, I discovered that the issue stemmed from the form_tag in ui/table/component.html.erb not being explicitly closed, which resulted in subsequent form tags disappearing.

``` rb
<%= render component("ui/table/toolbar").new("data-#{stimulus_id}-target": "batchToolbar", role: "toolbar", "aria-label": t(".batch_actions"), hidden: true) do %>
  <%= form_tag '', id: batch_actions_form_id %>
  <% @data.batch_actions.each do |batch_action| %>
    <%= render_batch_action_button(batch_action) %>
  <% end %>
<% end %>
```

Due to the lack of a proper block structure closing the form_tag, the HTML became malformed, and any form tags declared afterward were not rendered.

Updated the form_tag to use a block form, ensuring that the opening and closing tags are explicitly defined.
@swamp09 swamp09 requested a review from a team as a code owner March 3, 2025 09:25
@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 3, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 86.64%. Comparing base (d00c324) to head (6949386).
Report is 6 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6172      +/-   ##
==========================================
+ Coverage   85.71%   86.64%   +0.93%     
==========================================
  Files         443      514      +71     
  Lines       10081    11894    +1813     
==========================================
+ Hits         8641    10306    +1665     
- Misses       1440     1588     +148     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown
Member

@tvdeyen tvdeyen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

@tvdeyen tvdeyen added the backport-v4.5 Backport this pull-request to v4.5 label Mar 3, 2025
@tvdeyen tvdeyen merged commit 2d70d96 into solidusio:main Mar 6, 2025
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Mar 6, 2025

💔 All backports failed

Status Branch Result
v4.5 An unhandled error occurred. Please see the logs for details

Manual backport

To create the backport manually run:

backport --pr 6172

Questions ?

Please refer to the Backport tool documentation and see the Github Action logs for details

@tvdeyen
Copy link
Copy Markdown
Member

tvdeyen commented Mar 6, 2025

💚 All backports created successfully

Status Branch Result
v4.5

Questions ?

Please refer to the Backport tool documentation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-v4.5 Backport this pull-request to v4.5 changelog:solidus_admin

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants