feat: Make hook viewportSubscriptionOptions in viewport hooks partial#2627
Conversation
There was a problem hiding this comment.
Pull request overview
This PR makes the viewportSubscriptionOptions parameter partial in the viewport-related hooks (useViewportData and useSetPaddedViewportCallback), allowing users to customize subscription options without having to manually specify rows and columns, which are now automatically filled in by the hooks based on the viewport state.
Changes:
- Changed
viewportSubscriptionOptionsparameter type fromdh.ViewportSubscriptionOptionstoPartial<dh.ViewportSubscriptionOptions>in both hooks - Implemented logic to automatically fill in missing
rowsandcolumnsproperties using nullish coalescing when creating viewport subscriptions - Added comprehensive test coverage for the new behavior, including scenarios with missing rows, missing columns, and missing both properties
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| packages/jsapi-components/src/useViewportData.ts | Updated type signature and documentation for viewportSubscriptionOptions parameter to accept Partial<dh.ViewportSubscriptionOptions> |
| packages/jsapi-components/src/useSetPaddedViewportCallback.ts | Updated parameter type, ref type, and implementation to automatically fill in missing rows and columns when creating viewport subscriptions; added documentation |
| packages/jsapi-components/src/useSetPaddedViewportCallback.test.ts | Added comprehensive test coverage for the new auto-fill behavior with three scenarios: missing rows, missing columns, and missing both |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2627 +/- ##
==========================================
- Coverage 49.78% 49.77% -0.01%
==========================================
Files 774 774
Lines 43767 43770 +3
Branches 11256 11258 +2
==========================================
- Hits 21789 21788 -1
- Misses 21960 21964 +4
Partials 18 18
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| columns: table.columns, | ||
| }; | ||
| viewportOptionsMissingRows = { | ||
| columns: table.columns, |
There was a problem hiding this comment.
Minor issue with this test data is that columns is the same reference that gets included as the default. Might want to differentiate.
bmingles
left a comment
There was a problem hiding this comment.
minor comment on test case
bmingles
left a comment
There was a problem hiding this comment.
Left a question about the mock proxy usage
I'm attempting to use one of these hooks for DH-21214. I have an array column that I need to pull all the data out of, so I need to customize the viewportSubscriptionOptions. Currently these hooks require you to pass in the whole object, but I think the rows and columns should be automatically replaced if you just want to customize the other options.