🐛(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:
committed by
aleb_the_flash
parent
a5d8aae293
commit
a83afdbb0c
@@ -58,6 +58,8 @@ const SelectDevicePermissions = <T extends string | number>({
|
|||||||
setActiveMediaDevice(items[0].value)
|
setActiveMediaDevice(items[0].value)
|
||||||
}, [items, onSubmit, kind, setActiveMediaDevice, activeDeviceId])
|
}, [items, onSubmit, kind, setActiveMediaDevice, activeDeviceId])
|
||||||
|
|
||||||
|
const selectedKey = id || activeDeviceId
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Select
|
<Select
|
||||||
aria-label={t(`${kind}.choose`)}
|
aria-label={t(`${kind}.choose`)}
|
||||||
@@ -66,8 +68,9 @@ const SelectDevicePermissions = <T extends string | number>({
|
|||||||
items={items}
|
items={items}
|
||||||
iconComponent={iconComponent}
|
iconComponent={iconComponent}
|
||||||
placeholder={items.length === 0 ? t('loading') : t('select')}
|
placeholder={items.length === 0 ? t('loading') : t('select')}
|
||||||
selectedKey={id || activeDeviceId}
|
selectedKey={selectedKey}
|
||||||
onSelectionChange={(key) => {
|
onSelectionChange={(key) => {
|
||||||
|
if (key === selectedKey) return
|
||||||
onSubmit?.(key as string)
|
onSubmit?.(key as string)
|
||||||
setActiveMediaDevice(key as string)
|
setActiveMediaDevice(key as string)
|
||||||
}}
|
}}
|
||||||
|
|||||||
Reference in New Issue
Block a user