Skip to content

Use CanvasContext / url as source of truth - NOREF#544

Merged
sarangj merged 2 commits into
qafrom
url_state2
Mar 26, 2026
Merged

Use CanvasContext / url as source of truth - NOREF#544
sarangj merged 2 commits into
qafrom
url_state2

Conversation

@sarangj

@sarangj sarangj commented Mar 26, 2026

Copy link
Copy Markdown
Contributor

Ticket:

  • NOREF

This PR does the following:

Some followup cleanup as I've learned a bit more about nextJS / context

The state was a bit hard to follow between the data provided by the
canvas context and the props passed down explicitly. Additionally, it
seems that we can use nextJS native hooks to get / set the canvas index,
allowing us to remove some of the use of window APIs.

Disclosure - the updates to useCanvasContext were generated using
gemini. Everything else is artisanal. Also, note the use of scroll: false in router.push. That was a manual update to prevent the focus
from being disrupted when paging to the next canvas.

Open questions

How has this been tested? How should a reviewer test this?

Accessibility concerns or updates

Checklist:

  • I have added relevant accessibility documentation for this pull request.
  • All new and existing tests passed.
  • I have updated the CHANGELOG.md.

@vercel

vercel Bot commented Mar 26, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
digital-collections Ready Ready Preview, Comment Mar 26, 2026 7:10pm

Request Review

The state was a bit hard to follow between the data provided by the
canvas context and the props passed down explicitly. Additionally, it
seems that we can use nextJS native hooks to get / set the canvas index,
allowing us to remove some of the use of window APIs.

Disclosure - the updates to useCanvasContext were generated using
gemini. Everything else is artisinal. Also, note the use of `scroll:
false` in `router.push`. That was a manual update to prevent the focus
from being disrupted when paging to the next canvas.
@sarangj sarangj changed the title Url state2 Use CanvasContext / url as source of truth - NOREF Mar 26, 2026
@sarangj sarangj marked this pull request as ready for review March 26, 2026 19:00
Comment thread app/src/components/items/viewer/viewer.tsx Outdated
canvasIndex
);
}
}, [canvasIndex, uv]);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I believe just using canvasIndex as a dep here removes the need to track the last canvas index ref.

@keithbauer keithbauer left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nice, looks good in the vercel preview

@sarangj sarangj merged commit 2a0a4e7 into qa Mar 26, 2026
9 checks passed
@sarangj sarangj deleted the url_state2 branch March 26, 2026 19:42
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.

2 participants