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 issue #1136 (open correct product tabs) #1220

Closed
wants to merge 1 commit into from
Closed

Fix issue #1136 (open correct product tabs) #1220

wants to merge 1 commit into from

Conversation

flair-duncan
Copy link
Contributor

@flair-duncan flair-duncan commented May 2, 2018

What?

When the product page URL contains a fragment identifier that relates to tabbed content, i.e. #tab-similar or #tab-warranty, the correct tab should appear when the page loads.

Related Issue

Screenshots

Before

before-changes

After

after-changes

@bigbot
Copy link

bigbot commented May 2, 2018

Autotagging @bigcommerce/storefront-team @davidchin

* Check for fragment identifier in URL requesting a specific tab
*/
getTabRequests() {
if (window.location.hash && window.location.hash.indexOf('#tab-similar') === 0 || window.location.hash.indexOf('#tab-warranty') === 0) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we not have hardcoded check for the hash in here. Bcoz there could be different ones e.g. http://cornerstone-light-demo.mybigcommerce.com/all/able-brewing-system/ is a cornerstone demo store in which we have #tab-related which doesn't exist in the check. May be we just check if hash exists & .tabs has a href with that hash.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@junedkazi #tab-related is open by default, as is #tab-description, which is why I'm only checking for the others. I guess removing the hardcoded checks would allow for future tabs or custom added ones?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes it would support any new ones we plan to add in the future or any custom ones which a theme developer will add while working on their custom theme.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Are we OK to go with

if (window.location.hash && window.location.hash.indexOf('#tab') === 0) {

to ensure we're actually requesting a tab and not, for instance, the reviews panel, i.e. #product-reviews ?

* Check for fragment identifier in URL requesting a specific tab
*/
getTabRequests() {
if (window.location.hash && window.location.hash.indexOf('#tab-') === 0) {
Copy link
Contributor

Choose a reason for hiding this comment

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

👏 I like this much better.

Copy link
Contributor

@junedkazi junedkazi left a comment

Choose a reason for hiding this comment

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

Can you add some before & after screenshot or video

@junedkazi
Copy link
Contributor

Also this PR might need a rebase. Let's hold off on doing it right away. Let's get the duplicate ids PR merged before we rebase this one.

@mattolson mattolson dismissed junedkazi’s stale review May 18, 2018 23:17

Comment has been addressed.

const $activeTab = $('.tabs').has(`[href='${window.location.hash}']`);
const $tabContent = $(`${window.location.hash}`);

$activeTab.find('.tab')
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we have a guard in case someone uses a url fragment that doesn't actually match a tab element on the page?

@junedkazi
Copy link
Contributor

@flair-duncan thanks for all the work on this PR. Do you have any availability to see this PR through ? This is really close. If you could just address Matt's comment & rebase the PR to fix the conflicts I think this PR is good to go.

@flair-duncan
Copy link
Contributor Author

Closed in favor of #1304

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

Successfully merging this pull request may close these issues.

4 participants