🐛(frontend) prevent state updates when device selection unchanged

Skip state updates when selected device hasn't actually changed to
prevent unnecessary re-renders that caused visible camera track
blinking.

Improves user experience by eliminating visual artifacts during device
selection interactions when no actual change occurs.
This commit is contained in:
lebaudantoine
2025-08-22 12:22:52 +02:00
committed by aleb_the_flash
parent a5d8aae293
commit a83afdbb0c

View File

@@ -58,6 +58,8 @@ const SelectDevicePermissions = <T extends string | number>({
setActiveMediaDevice(items[0].value)
}, [items, onSubmit, kind, setActiveMediaDevice, activeDeviceId])
const selectedKey = id || activeDeviceId
return (
<Select
aria-label={t(`${kind}.choose`)}
@@ -66,8 +68,9 @@ const SelectDevicePermissions = <T extends string | number>({
items={items}
iconComponent={iconComponent}
placeholder={items.length === 0 ? t('loading') : t('select')}
selectedKey={id || activeDeviceId}
selectedKey={selectedKey}
onSelectionChange={(key) => {
if (key === selectedKey) return
onSubmit?.(key as string)
setActiveMediaDevice(key as string)
}}