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 active-tab selection for different page contexts #3212

Merged
merged 3 commits into from
Oct 18, 2023
Merged

Conversation

whyoleg
Copy link
Contributor

@whyoleg whyoleg commented Oct 16, 2023

fixes #2899

@whyoleg whyoleg self-assigned this Oct 16, 2023
@@ -18,8 +18,6 @@ const samplesLightThemeName = 'idea'
window.addEventListener('load', () => {
document.querySelectorAll("div[data-platform-hinted]")
.forEach(elem => elem.addEventListener('click', (event) => togglePlatformDependent(event, elem)))
document.querySelectorAll("div[tabs-section]")
Copy link
Contributor Author

@whyoleg whyoleg Oct 16, 2023

Choose a reason for hiding this comment

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

the code was removed here because it duplicates the same code that was already in initTabs function, which is called later

Copy link
Member

@IgnatBeresnev IgnatBeresnev left a comment

Choose a reason for hiding this comment

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

Nice job with refactoring!

@@ -163,6 +163,7 @@ public open class HtmlRenderer(
contentTabs.forEachIndexed { index, contentTab ->
button(classes = "section-tab") {
if (index == 0) attributes["data-active"] = ""
attributes["data-type"] = pageContext.getDocumentableType() ?: ""
Copy link
Member

Choose a reason for hiding this comment

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

Oh btw, it might be worth adding a test that verifies that this attribute exists on the pages, and adding a comment to these tests that the value is used in js tab-handling scripts wouldn't hurt. Should be a simple and quick intro into writing html tests as well

We don't have any UI tests, so if this gets lost during refactoring or someone thinks it's not needed, it might lead to regression.

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 reuse .main-content[data-page-type] for the purpose? Currently, the attribute is created for every tab. We are trying to decrease the size of the generated HTML.

Also, it seems to make no sense to have an empty attribute if getDocumentableType() returns null.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@vmishenev thanks! You are right, I was thinking, that it will be harder to reusing it, but in the end it simplified code a lot :)
Pushed changes with usage of it.

So I will now add test for checking that just data-page-type attribute is present on page

@whyoleg whyoleg requested a review from IgnatBeresnev October 17, 2023 15:28
@whyoleg
Copy link
Contributor Author

whyoleg commented Oct 17, 2023

Ready for review

Copy link
Member

@IgnatBeresnev IgnatBeresnev left a comment

Choose a reason for hiding this comment

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

👍

@whyoleg whyoleg merged commit f225faf into master Oct 18, 2023
9 checks passed
@whyoleg whyoleg deleted the fix-active-tab branch October 18, 2023 15:28
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.

active-tab value reused in different set of tabs
3 participants