Skip to content

Prevent crash when settings control is enabled in ControlBar #1177

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

smorimoto
Copy link

The ControlBar component would crash when settings: true was set in the controls prop, despite being defined in the type definition. This occurred because the SettingsMenuToggle component was using useLayoutContext() which throws an error when no LayoutContext is provided.

Changed useLayoutContext() to useMaybeLayoutContext() in the useSettingsToggle hook to gracefully handle cases where LayoutContext is not available, preventing the crash and allowing the settings control to work properly.

Copy link

changeset-bot bot commented Jul 2, 2025

🦋 Changeset detected

Latest commit: 7193449

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 5 packages
Name Type
@livekit/components-react Patch
@livekit/component-example-next Patch
@livekit/components-js-docs Patch
@livekit/component-docs-storybook Patch
@livekit/components-docs-gen Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@CLAassistant
Copy link

CLAassistant commented Jul 2, 2025

CLA assistant check
All committers have signed the CLA.

Replace `useLayoutContext()` with `useMaybeLayoutContext()` in
`useSettingsToggle` to handle cases where `LayoutContext` is not
provided, preventing crashes when settings control is enabled in
`ControlBar` component.

Signed-off-by: Sora Morimoto <[email protected]>
@smorimoto smorimoto force-pushed the fix-control-bar-settings-crash branch from 531ad92 to 7193449 Compare July 2, 2025 07:54
@smorimoto smorimoto marked this pull request as draft July 2, 2025 08:29
@smorimoto
Copy link
Author

I actually noticed that this also happens with other properties like chat. I will look into whether other appropriate fixes might be available later.

Copy link
Contributor

@lukasIO lukasIO left a comment

Choose a reason for hiding this comment

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

thanks for the fix!

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.

3 participants