Skip to content

fix(usePlaybackOptions): clear screen regions when screenRegions is unset#12

Open
andriiboliboksc wants to merge 8 commits into
Snapchat:mainfrom
andriiboliboksc:patch-1
Open

fix(usePlaybackOptions): clear screen regions when screenRegions is unset#12
andriiboliboksc wants to merge 8 commits into
Snapchat:mainfrom
andriiboliboksc:patch-1

Conversation

@andriiboliboksc

@andriiboliboksc andriiboliboksc commented Jul 9, 2026

Copy link
Copy Markdown

What changed

The screenRegions effect bails on any falsy value, so passing undefined never calls setScreenRegions and previously-set regions can't be cleared via the prop.

Drop the falsy guard and coalesce unset → {}. Since setScreenRegions is full-replacement (empty object clears all regions), the hook is now properly declarative: pass regions to set them, omit/undefined to clear.

@andriiboliboksc andriiboliboksc marked this pull request as ready for review July 9, 2026 18:23

@msilivonik-sc msilivonik-sc left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think treating undefined as empty makes sense for this API, because screenRegions is intended to be a fully declarative prop: the value represents the complete desired region set, so omitting it means no regions should be active.

Also let's update comment of screenRegions here and here:

/**
 * Configuration object containing the complete set of active screen regions.
 *
 * Screen regions define areas of the screen that have special meaning for Lens rendering,
 * such as safe rendering areas, UI button locations, keyboard areas, etc. This allows lenses
 * to adapt their content placement based on the host application's UI layout.
 *
 * This value is applied as a full replacement set: regions not included in the object are
 * removed. Pass `undefined` or omit this option to clear all screen regions.
 */
screenRegions?: ScreenRegions;

Comment thread src/usePlaybackOptions.test.ts
@andriiboliboksc

Copy link
Copy Markdown
Author

@msilivonik-sc added should clear screen regions when they change from set to undefined (renders with regions, rerenders with undefined, asserts setScreenRegions({})). Also updated the screenRegions doc comment in both files as suggested.

@msilivonik-sc msilivonik-sc left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM! Thanks!

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