55 VersionItem ,
66 SuiteResult ,
77 ConformanceState ,
8- SortOption ,
98} from "@site/src/components/conformance/types" ;
109import ResultNavigation from "./nav" ;
1110import {
@@ -28,8 +27,16 @@ export default function ResultsDisplay(props: ResultsProps): JSX.Element {
2827 // Refs
2928 const activeResults = React . useRef < undefined | ResultInfo > ( ) ;
3029
30+ // History handling
3131 const history = useHistory < ConformanceState > ( ) ;
3232
33+ const pushStateToHistory = ( state : ConformanceState ) : void => {
34+ history . push ( {
35+ pathname : "/conformance" ,
36+ state,
37+ } ) ;
38+ } ;
39+
3340 React . useEffect ( ( ) => {
3441 // If the version is correctly synced
3542 if ( props . state . version . tagName !== activeResults . current ?. version ) {
@@ -60,7 +67,6 @@ export default function ResultsDisplay(props: ResultsProps): JSX.Element {
6067 const updateActiveResults = async ( ) : Promise < ResultInfo > => {
6168 const data = await fetchResults ( props . state . version ) ;
6269 return mapToResultInfo ( props . state . version . tagName , data ) ;
63- // setCurrentSuite(resultInfo.results);
6470 } ;
6571
6672 const findResultsFromPath = ( activeResultsInfo : ResultInfo ) : SuiteResult => {
@@ -84,72 +90,67 @@ export default function ResultsDisplay(props: ResultsProps): JSX.Element {
8490 // Navigates to a suite by adding the SuiteName to the test path array.
8591 const navigateToSuite = ( newSuiteName : string ) => {
8692 const newPath = [ ...props . state . testPath , newSuiteName ] ;
87- history . push ( {
88- pathname : "/conformance" ,
89- state : createState (
93+ pushStateToHistory (
94+ createState (
9095 props . state . version ,
9196 newPath ,
9297 props . state . ecmaScriptVersion ,
9398 props . state . sortOption ,
9499 ) ,
95- } ) ;
100+ ) ;
96101 } ;
97102
98103 // Removes a value or values from the test path array.
99104 //
100105 // Used by breadcrumbs for navigation.
101106 const sliceNavToIndex = ( nonInclusiveIndex : number ) => {
102107 const slicedPath = [ ...props . state . testPath . slice ( 0 , nonInclusiveIndex ) ] ;
103- history . push ( {
104- pathname : "/conformance" ,
105- state : createState (
108+ pushStateToHistory (
109+ createState (
106110 props . state . version ,
107111 slicedPath ,
108112 props . state . ecmaScriptVersion ,
109113 props . state . sortOption ,
110114 ) ,
111- } ) ;
115+ ) ;
112116 } ;
113117
114118 // Sets the ECMAScript version flag value.
115119 const setEcmaScriptFlag = ( flag : string ) => {
116120 const nulledFlag = flag ? flag : undefined ;
117- history . push ( {
118- pathname : "/conformance" ,
119- state : createState (
121+ pushStateToHistory (
122+ createState (
120123 props . state . version ,
121124 props . state . testPath ,
122125 nulledFlag ,
123126 props . state . sortOption ,
124127 ) ,
125- } ) ;
128+ ) ;
126129 } ;
127130
128131 // Sets the sorting option
129132 const setSortOption = ( option : string ) => {
130- history . push ( {
131- pathname : "/conformance" ,
132- state : createState (
133+ pushStateToHistory (
134+ createState (
133135 props . state . version ,
134136 props . state . testPath ,
135137 props . state . ecmaScriptVersion ,
136138 option ,
137139 ) ,
138- } ) ;
140+ ) ;
139141 } ;
140142
141143 // Sets a selected test.
142144 const setSelectedTest = ( test : string | undefined ) => {
143- history . push ( {
144- pathname : "/conformance" ,
145- state : createState (
145+ pushStateToHistory (
146+ createState (
146147 props . state . version ,
147148 props . state . testPath ,
148149 props . state . ecmaScriptVersion ,
149150 props . state . sortOption ,
150151 test ,
151152 ) ,
152- } ) ;
153+ ) ;
153154 } ;
154155
155156 // Create the t262 URL from testPath with the results commit
0 commit comments