Skip to content

Allow for functional links in amp-accordion headers#9335

Merged
kmh287 merged 21 commits intoampproject:masterfrom
kmh287:amp_accordion_header_links
May 26, 2017
Merged

Allow for functional links in amp-accordion headers#9335
kmh287 merged 21 commits intoampproject:masterfrom
kmh287:amp_accordion_header_links

Conversation

@kmh287
Copy link
Copy Markdown
Contributor

@kmh287 kmh287 commented May 15, 2017

This PR allows links in accordion headers that can be pressed without expanding or collapsing the corresponding accordion section.

Fixes #7712

/to @aghassemi

@kmh287 kmh287 force-pushed the amp_accordion_header_links branch from 69970be to cc85994 Compare May 25, 2017 15:23
@kmh287 kmh287 changed the title [WIP] Allow for functional links and buttons in amp-accordion headers [WIP] Allow for functional links in amp-accordion headers May 25, 2017
@kmh287 kmh287 requested a review from aghassemi May 26, 2017 15:55
@kmh287 kmh287 changed the title [WIP] Allow for functional links in amp-accordion headers Allow for functional links in amp-accordion headers May 26, 2017
// for buttons and links, which should not have their default behavior
// overidden.
const target = dev().assertElement(event.target);
if (target.tagName != 'A') {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we support anything else here besides anchor tags?

// for on links, which should not have their default behavior
// overidden.
const target = dev().assertElement(event.target);
if (target.tagName != 'A') {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this may not work for image links (<a href><amp-img>...). I think we need to check all the ancestors of target up to the header element. ancestorElements(child, predicate) should help find it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

Copy link
Copy Markdown
Contributor

@aghassemi aghassemi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@kmh287
Copy link
Copy Markdown
Contributor Author

kmh287 commented May 26, 2017

Thanks!

@kmh287 kmh287 merged commit ec17a98 into ampproject:master May 26, 2017
@ericlindley-g
Copy link
Copy Markdown
Contributor

Nice—thanks for jumping in on this, @kmh287 ! /cc @camelburrito as FYI

@camelburrito
Copy link
Copy Markdown
Contributor

We should not be doing this in accordion, ideally what you need in #7712 could be achieved by using amp-selector. This goes against what an accordion is supposed to do.

Could you hold on this till Tuesday when i am back.
@ericlindley-g

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants