@tanstack/router-devtools 0.0.1-beta.100 → 0.0.1-beta.102

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tanstack/router-devtools",
3
3
  "author": "Tanner Linsley",
4
- "version": "0.0.1-beta.100",
4
+ "version": "0.0.1-beta.102",
5
5
  "license": "MIT",
6
6
  "repository": "tanstack/router",
7
7
  "homepage": "https://tanstack.com/router/",
package/src/devtools.tsx CHANGED
@@ -412,27 +412,32 @@ function RouteComp({
412
412
  route,
413
413
  isRoot,
414
414
  matches,
415
+ activeRouteId,
416
+ setActiveRouteId,
415
417
  }: {
416
418
  route: AnyRootRoute | AnyRoute
417
419
  isRoot?: boolean
418
420
  matches: RouteMatch[]
421
+ activeRouteId: string | undefined
422
+ setActiveRouteId: (id: string) => void
419
423
  }) {
420
424
  const isActive = matches.find((d) => d.route === route)
421
425
  return (
422
426
  <div>
423
427
  <div
424
- // role="button"
425
- // aria-label={`Open match details for ${route.id}`}
426
- // onClick={() =>
427
- // setActiveRouteId(activeRouteId === route.id ? '' : route.id)
428
- // }
428
+ role="button"
429
+ aria-label={`Open match details for ${route.id}`}
430
+ onClick={() => {
431
+ if (isActive)
432
+ setActiveRouteId(activeRouteId === route.id ? '' : route.id)
433
+ }}
429
434
  style={{
430
435
  display: 'flex',
431
436
  borderBottom: `solid 1px ${theme.grayAlt}`,
432
- cursor: 'pointer',
437
+ cursor: isActive ? 'pointer' : 'default',
433
438
  alignItems: 'center',
434
- // background:
435
- // route === activeMatch ? 'rgba(255,255,255,.1)' : undefined,
439
+ background:
440
+ route.id === activeRouteId ? 'rgba(255,255,255,.1)' : undefined,
436
441
  }}
437
442
  >
438
443
  {isRoot ? null : (
@@ -468,7 +473,13 @@ function RouteComp({
468
473
  }}
469
474
  >
470
475
  {(route.children as Route[]).map((r) => (
471
- <RouteComp key={r.id} route={r} matches={matches} />
476
+ <RouteComp
477
+ key={r.id}
478
+ route={r}
479
+ matches={matches}
480
+ activeRouteId={activeRouteId}
481
+ setActiveRouteId={setActiveRouteId}
482
+ />
472
483
  ))}
473
484
  </div>
474
485
  ) : null}
@@ -508,15 +519,6 @@ export const TanStackRouterDevtoolsPanel = React.forwardRef<
508
519
  '',
509
520
  )
510
521
 
511
- const [activeMatchId, setActiveMatchId] = useLocalStorage(
512
- 'tanstackRouterDevtoolsActiveMatchId',
513
- '',
514
- )
515
-
516
- React.useEffect(() => {
517
- setActiveMatchId('')
518
- }, [activeRouteId])
519
-
520
522
  const allMatches: RouteMatch[] = React.useMemo(
521
523
  () => [
522
524
  ...Object.values(router.state.currentMatches),
@@ -525,9 +527,7 @@ export const TanStackRouterDevtoolsPanel = React.forwardRef<
525
527
  [router.state.currentMatches, router.state.pendingMatches],
526
528
  )
527
529
 
528
- const activeMatch =
529
- allMatches?.find((d) => d.id === activeMatchId) ||
530
- allMatches?.find((d) => d.route.id === activeRouteId)
530
+ const activeMatch = allMatches?.find((d) => d.route.id === activeRouteId)
531
531
 
532
532
  const hasSearch = Object.keys(
533
533
  last(router.state.currentMatches)?.state.search || {},
@@ -698,7 +698,13 @@ export const TanStackRouterDevtoolsPanel = React.forwardRef<
698
698
  </button>
699
699
  </div>
700
700
  {!showMatches ? (
701
- <RouteComp route={router.routeTree} isRoot matches={allMatches} />
701
+ <RouteComp
702
+ route={router.routeTree}
703
+ isRoot
704
+ matches={allMatches}
705
+ activeRouteId={activeRouteId}
706
+ setActiveRouteId={setActiveRouteId}
707
+ />
702
708
  ) : (
703
709
  <div>
704
710
  {router.state.currentMatches.map((match, i) => {