Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@
<commonmark.version>0.23.0</commonmark.version>
<antlr.version>4.5</antlr.version>
<jackson.version>2.19.1</jackson.version>
<webtau.version>2.2</webtau.version>
<webtau.version>2.4</webtau.version>
<jaxb.version>2.3.0</jaxb.version>
<ant.version>1.10.11</ant.version>
<ant-compress.version>1.5</ant-compress.version>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* Fix: Focus page content on page open or search open regression
8 changes: 7 additions & 1 deletion znai-reactjs/src/layout/DocumentationLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

import React, { useRef, useState } from "react";
import React, { useEffect, useRef, useState } from "react";

import TocPanel from "./TocPanel";
import { PageGenError } from "../doc-elements/page-gen-error/PageGenError";
Expand Down Expand Up @@ -95,6 +95,12 @@ export function DocumentationLayout({

const panelFullClassName = mainPanelClassName + (isMobile ? " mobile" : "");

useEffect(() => {
if (contentRef.current) {
contentRef.current.focus();
}
}, [selectedTocItem]);

return isMobile ? renderMobile() : renderDesktop();

function renderPageContent() {
Expand Down
7 changes: 7 additions & 0 deletions znai-tests/src/test/groovy/scenarios/docsContent.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,13 @@ scenario('table of contents navigation') {
browser.title.should == "Your Product: Page Three"
}

scenario('main content should have focus on page load and after navigation') {
browser.open(scaffoldServerUrl.get() + '/my-product/chapter-one/getting-started')
standardView.pageTitle.waitTo == "Getting Started"
browser.sendKeys(browser.keys.pageDown)
standardView.mainPanelScrollTop.waitToBe > 100
}

scenario('navigating back and forth should preserve scroll position') {
standardView.gettingStartedTocItem.click()
standardView.metaSection.waitTo visible
Expand Down