Skip to content

Elements with non-unique ID on filtering pages #4584

@ahukkanen

Description

@ahukkanen

Describe the bug
On the listing pages that have filtering on them (such as proposals, meetings, etc.), the filtering DOM elements are duplicated in the source with the same IDs.

This causes e.g. Chrome to show the following error in the developer console:

[DOM] Found 2 elements with non-unique id #element_id: (More info: https://goo.gl/9p2vKq)

To Reproduce
Steps to reproduce the behavior:

  1. Go to https://meta.decidim.org/processes/roadmap/f/122/
  2. Open developer console (CTRL+SHIFT+J in Chrome)
  3. See the DOM errors printed out

Expected behavior
I would expect the HTML of the service to be valid and not cause DOM issues.

Screenshots
decidim-element-issues

Stacktrace
If applicable, add the error stacktrace to help explain your problem.

Extra data (please complete the following information):

  • Device: Laptop
  • Device OS: Ubuntu 18.01
  • Browser: Chrome
  • Decidim Version: 0.15.1 (also tested the master branch)
  • Decidim installation: all, e.g. MetaDecidim

Additional context
This issue exists because the filtering elements are duplicated for the mobile browsers in the filtering modal/reveal element as seen here:

<%= render partial: "filters_small_view" %>
<div class="card card--secondary show-for-mediumlarge">
<%= render partial: "filters" %>

Furthermore, the part of the template that is rendered for the small screens re-renders the _filters.html.erb partial as seen here:

And finally, the filters template uses the default Rails/Foundation helpers to render the filtering inputs for which the IDs are auto-generated using the field's key:
https://github.com/decidim/decidim/blob/fc9b0cb887b2f2a5a8b0e170b6316eba9ef41172/decidim-proposals/app/views/decidim/proposals/proposals/_filters.html.erb

https://github.com/rails/rails/blob/66a7cfa91045e05f134efc9ac0e226e66161e2e6/actionview/lib/action_view/helpers/tags/base.rb#L99-L106

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions