Skip to content

Fix table_cell_selector generating invalid CSS class for column names with slashes#46

Merged
senid231 merged 3 commits intomasterfrom
copilot/fix-table-cell-slesh-error
Apr 9, 2026
Merged

Fix table_cell_selector generating invalid CSS class for column names with slashes#46
senid231 merged 3 commits intomasterfrom
copilot/fix-table-cell-slesh-error

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 8, 2026

have_table_cell(column: 'Country / Region') would build the selector td.col.col-country_/_region — a valid-looking but never-matching CSS class — instead of td.col.col-country_region, which is what Active Admin actually generates.

Changes

  • lib/capybara/active_admin/selectors/table.rb: Updated table_cell_selector to strip non-alphanumeric characters before converting spaces to underscores and squeezing duplicates:

    # Before
    column = column.to_s.gsub(' ', '_').downcase
    # After
    column = column.to_s.downcase.gsub(/[^a-z0-9\s]/, '').gsub(/\s+/, '_').squeeze('_')
  • spec/lib/selectors/table_spec.rb: Unit tests for table_cell_selector covering slash-separated labels ('Country / Region'), parenthesized suffixes ('Price (USD)'), and standard multi-word names.

Copilot AI changed the title [WIP] Fix error in have_table_cell when using slashes in column names Fix table_cell_selector generating invalid CSS class for column names with slashes Apr 8, 2026
Copilot AI requested a review from senid231 April 8, 2026 12:49
@senid231 senid231 marked this pull request as ready for review April 9, 2026 10:37
@senid231 senid231 merged commit 4dfbd59 into master Apr 9, 2026
37 checks passed
@senid231 senid231 deleted the copilot/fix-table-cell-slesh-error branch April 9, 2026 11:21
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.

have_table_cell has error when build cell using slesh

2 participants