Skip to content

Collapse multi-target fails with "#id1, #id2" data-target selector #25273

Description

@bpierson

Fiddle

With a comma-separated CSS selector, the targeted collapsible elements are not toggled, for example:
data-target="#coll1, #coll2"

No error is raised.

Activity

  1. MartijnCuppens commented on Jan 11, 2018

    @MartijnCuppens
    Member

    An aria-expanded attribute is added to the toggle button to indicate if the collapsible element is collapsed or not. If you target multiple collapsible elements which have different states (collapsed and shown), it's impossible to determine the aria-expanded state of the toggle button.

    I don't know if there are (accessible) solutions for this situation.

  2. patrickhlauke commented on Jan 11, 2018

    @patrickhlauke
    Member

    this is a valid bug related to http://getbootstrap.com/docs/4.0/components/collapse/#multiple-targets

    @MartijnCuppens as for the aria-expanded, you're right that if the multiple targets aren't all either expanded or collapsed, the aria-expanded will become meaningless. interesting edge case, as i'm not sure it's intended. might be worth filing a separate issue for it.

  3. added
    jsJavaScript or TypeScript sources and plugins
    v4v4, the frozen docs on gh-pages
    on Jan 11, 2018
  4. bpierson commented on Jan 11, 2018

    @bpierson
    Author

    @MartijnCuppens , @patrickhlauke that's true about the aria-expanded, but wouldn't it be true in any case using the example from the docs that takes a class selector (and works correctly)? Thanks.

  5. patrickhlauke commented on Jan 11, 2018

    @patrickhlauke
    Member

    @bpierson yes, which is why i'm saying that particular thing should be a separate issue. the problem you reported is valid as per your description (the valid jquery selector you provide, with the two ids, isn't working as it should)

  6. bpierson commented on Jan 11, 2018

    @bpierson
    Author

    Won't SR's honor the display style of the collapsible element in question, irrespective of which element triggered it? Maybe aria-expanded on the trigger is overkill here. Don't want to get too far into the weeds and away from the OP, but using aria-expanded seems to be a non-starter if the "any selector" feature stays in place since the value can only be true or false.

  7. XhmikosR commented on Jan 12, 2018

    @XhmikosR
    Member
  8. Johann-S commented on Jan 12, 2018

    @Johann-S
    Member
  9. bpierson commented on Jan 12, 2018

    @bpierson
    Author

    @Johann-S I just confirmed that to be the case by just changing the value to " #coll1, #coll2", which worked as expected (note the space at index 0).

    I understand the motivation in trying to sanitize the id, but it seems like in the case of a selector it's a losing battle. Presumably the coder supplied both the id value and the data-target value, so it should really be up to them to make sure id values (and their corresponding href or attribute values) are pre-sanitized.

    I might humbly suggest that to simplify your code base, js libraries should just take what the coder supplies for attribute values - even ids.

  10. Johann-S commented on Jan 12, 2018

    @Johann-S
    Member

    Yep it seems they are a lot of use cases which are difficult to handle in our ends 😟

    Maybe we should add a warning in our documentation and remove that code

  11. bpierson commented on Jan 12, 2018

    @bpierson
    Author

    @Johann-S most systems that generate or template html have methods on the server side to sanitize id and attribute values before it ever gets to the browser. While it would technically be a breaking change, I doubt that it would have much impact. I've been programming about 30 years and in my experience, many issues are created by changing the value supplied by the user (side-effects). I've even run into problems just trimming off whitespace!

  12. miken32 commented on Jan 18, 2018

    @miken32

    I've run into this problem also, not with multiple targets but just using a more complicated target spec that started with #. I agree with the idea that the value should be passed to jQuery as-is, with no preprocessing.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    jsJavaScript or TypeScript sources and pluginsv4v4, the frozen docs on gh-pages

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions