Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for opening accordion item on iOS devices #355

Closed
Techn1x opened this issue Jun 13, 2017 · 14 comments
Closed

Fix for opening accordion item on iOS devices #355

Techn1x opened this issue Jun 13, 2017 · 14 comments
Labels

Comments

@Techn1x
Copy link
Contributor

Techn1x commented Jun 13, 2017

Thanks to @sukima for the fix

Before the ember-bootstrap beta.1 release, on iOS devices (or at least, iOS 10 anyway), clicking the accordion item anywhere didn't open the accordion.

On beta.1, it was now possible to click the title to open the accordion item (but clicking the accordion item itself still did not work.) This was likely due to this fix #311

It turns out, that iOS devices refuse to click on elements that aren't <button> or <a>. To allow clicking on other elements (such as <div>) need to apply the style cursor: pointer; to the element - doing this fixes the issue on iOS.

Should this style/class be added by default to accordion items so that they work on iOS? I can probably to a PR if needed

@srvance srvance added the bug label Jun 13, 2017
@srvance
Copy link
Contributor

srvance commented Jun 13, 2017

Thanks for filing this, @Techn1x. A PR would be great. Any opinion on this beforehand, @simonihmig?

@Techn1x
Copy link
Contributor Author

Techn1x commented Jun 15, 2017

I haven't done a lot of PR's on this project, what would be the best way to do this?

I went to add this:

/* iOS fix - elements aren't clickable without pointer */
  attributeBindings: ['style'],
  style: 'cursor:pointer',

To the base bs-accordion item component here:
https://github.com/kaliber5/ember-bootstrap/blob/master/addon/components/base/bs-accordion/item/title.js#L14-L37

Which works, but got a warning
WARNING: Binding style attributes may introduce cross-site scripting vulnerabilities;

Not really sure where to define classes for this addon either

@sukima
Copy link
Contributor

sukima commented Jun 15, 2017

You can get around that with this:

style: 'cursor:pointer'.htmlSafe()

But this is still dirty (and not something I would expect in an addon) instead I would leverage the component's class and add it into the CSS. What confuses me is why the Bootstrap CSS that this addon imports does not already have this in their accordion styles.

@srvance
Copy link
Contributor

srvance commented Jun 15, 2017

@sukima Is this BS3 or BS4? They're not really doing anything on BS3 now and this may not have been a behavior they anticipated when BS3 was under development. If it still exists in BS4, it should be an issue against twbs/bootstrap while they're still bringing it to fruition.

@sukima
Copy link
Contributor

sukima commented Jun 15, 2017

I don't know

@srvance
Copy link
Contributor

srvance commented Jun 15, 2017

What do you see when you run ember bootstrap:info? Can you paste the results here?

@Techn1x
Copy link
Contributor Author

Techn1x commented Jun 15, 2017

Definitely BS3, not sure if issue is present in BS4.

I found a better fix for this. Inside native BS3 stylesheets there is this that I could use for accordion items;

// iOS "clickable elements" fix for role="button"
//
// Fixes "clickability" issue (and more generally, the firing of events such as focus as well)
// for traditionally non-focusable elements with role="button"
// see https://developer.mozilla.org/en-US/docs/Web/Events/click#Safari_Mobile

[role="button"] {
  cursor: pointer;
}

As for BS4, this discussion looks relevant;
https://www.bountysource.com/issues/41219012-remove-cursor-pointer

But I am not sure what is the best way to proceed. I can add role="button" to the base accordion item, the other solution seems to be to add an empty click handler to target or any ancestor

@sukima
Copy link
Contributor

sukima commented Jun 16, 2017

I can add role="button" to the base accordion item

This looks like the best solution IMHO. I would 👍 this.

@sukima
Copy link
Contributor

sukima commented Jun 16, 2017

role="button" also adds accessibility to the accordion component which is a win win!

@simonihmig
Copy link
Contributor

Seems the original Bootstrap example does not support clicking the anywhere in the header, only on the <a>: http://getbootstrap.com/javascript/#collapse-example-accordion

The .panel-heading already has an ARIA role (role="tab") in line with the Bootstrap example. So adding role="button" would not be appropriate, I think?

Maybe we should add a app/styles/app.css file and put the cursor: pointer fix there, so this get's added to the apps styles automatically?

@Techn1x
Copy link
Contributor Author

Techn1x commented Jun 20, 2017

Hmm, in terms of UI and usability, that's a strange choice by bootstrap.... make something look like a button, but actually only the title acts like a button. I definitely prefer the approach of making the whole thing a button/tab.

So what's the best approach here, a more generic style like

[role="tab"] {
    cursor: pointer;
}

Or something specific to just accordions (would require making a new class, I think?)

.accordion-heading {
    cursor: pointer;
}

@sukima
Copy link
Contributor

sukima commented Jun 21, 2017

I like:

.panel-heading[role='tab'] {
  cursor: pointer;
}

And this should be in Bootstrap prime. Seriously.

seriously meme

@simonihmig
Copy link
Contributor

I added a PR that implements the fix that @sukima suggested: #369

Does that look ok for everybody? cc @Techn1x

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

No branches or pull requests

4 participants