Skip to content
This repository has been archived by the owner on May 29, 2019. It is now read-only.

Click in accordion-heading clears $location #4104

Closed
snajberk opened this issue Aug 4, 2015 · 7 comments
Closed

Click in accordion-heading clears $location #4104

snajberk opened this issue Aug 4, 2015 · 7 comments

Comments

@snajberk
Copy link

snajberk commented Aug 4, 2015

Hi,

I noticed a bug in a new version 0.13.2 (it is OK in 0.13.0).

I am using buttons inside of "accordion-heading" section, which worked fine in previous version, but latest release negatively affects location - it clears it completely. In other words: $location.path() is cleared after every single click on one of these buttons.

I created a plunker, so you should be able to easily check it. All you have to do is to open a preview window to see the URL.

Example usage:

    <accordion close-others="false">
      <accordion-group is-open="true">
        <accordion-heading>
          <div>
            Accordion heading
            <input type="button" ng-click="changeLocation($event)" value="Change location (broken)" />
          </div>
        </accordion-heading>

Plunker: http://plnkr.co/edit/Ub43PHtVxnPbmRzU0mAJ?p=preview

@wesleycho
Copy link
Contributor

Reproduction with latest from master here.

This looks like a problem for some reason with the anchor tag having href="#" ng-click="$event.preventDefault(); ..." - however, removing that creates accessibility problems.

@wesleycho
Copy link
Contributor

To expand on this, Bootstrap uses the anchor tag in accordions to hook into the cursor: pointer style, so removing the href completely does not seem to be a good option as that breaks CSS.

href="javascript:void(0)" is CSP non-compliant.

Any other href value, even an empty one, seems to require event.preventDefault() paired with it.

I'm a bit stumped as to the best approach here.

@pkozlowski-opensource
Copy link
Member

@wesleycho I remember this being a pb for quite some time and we've kept adding / removing this href back and forth. I wonder if <a href> instead of <a href="#"> would do the trick here? AngularJS should prevent default on empty hrefs, no?

@wesleycho
Copy link
Contributor

Aha, I found where I saw the issue with the empty href - #3799 . Perhaps that is more appropriately filed against the router though, if it hasn't been already.

I will change all usage to empty hrefs then.

@pkozlowski-opensource
Copy link
Member

Right. I think that there are some corner cases with empty href as well (I remember people reporting reload pbs with it), but I agree that we should track those pbs instead. In any case href="#" is not the best idea IMO.

@icfantv
Copy link
Contributor

icfantv commented Jan 28, 2016

Linking issues, #5361, #4777, #4533, and #3199. For the relevant conversation in Bootstrap, see this thread.

@roger2hk
Copy link

It seems using the empty href would cause issue #6262.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants