-
Notifications
You must be signed in to change notification settings - Fork 413
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
Conversation
@@ -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]") |
There was a problem hiding this comment.
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
There was a problem hiding this 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() ?: "" |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
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
Ready for review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
fixes #2899