mirror of
https://github.com/Stremio/stremio-web.git
synced 2026-04-21 03:22:11 +00:00
Multiselect autofocus first selected item
This commit is contained in:
parent
9a5e6ab01d
commit
07cfad8cd8
2 changed files with 11 additions and 7 deletions
|
|
@ -98,12 +98,16 @@ const Multiselect = ({ className, direction, title, renderLabelContent, renderLa
|
||||||
<div className={styles['menu-container']} onClick={popupMenuOnClick}>
|
<div className={styles['menu-container']} onClick={popupMenuOnClick}>
|
||||||
{
|
{
|
||||||
options.length > 0 ?
|
options.length > 0 ?
|
||||||
options.map(({ label, value }) => (
|
options.map(({ label, value }) => {
|
||||||
<Button key={value} className={classnames(styles['option-container'], { 'selected': selected.includes(value) })} title={typeof label === 'string' ? label : value} data-value={value} onClick={optionOnClick}>
|
const isSelected = selected.includes(value);
|
||||||
<div className={styles['label']}>{typeof label === 'string' ? label : value}</div>
|
const title = typeof label === 'string' ? label : value;
|
||||||
<Icon className={styles['icon']} icon={'ic_check'} />
|
return (
|
||||||
</Button>
|
<Button key={value} className={classnames(styles['option-container'], { 'selected': isSelected })} title={title} data-value={value} data-autofocus={isSelected ? true : null} onClick={optionOnClick}>
|
||||||
))
|
<div className={styles['label']}>{title}</div>
|
||||||
|
<Icon className={styles['icon']} icon={'ic_check'} />
|
||||||
|
</Button>
|
||||||
|
)
|
||||||
|
})
|
||||||
:
|
:
|
||||||
<div className={styles['no-options-container']}>
|
<div className={styles['no-options-container']}>
|
||||||
<div className={styles['label']}>No options available</div>
|
<div className={styles['label']}>No options available</div>
|
||||||
|
|
|
||||||
|
|
@ -68,7 +68,7 @@ const Popup = ({ open, direction, renderLabel, renderMenu, onCloseRequest, ...pr
|
||||||
ref: labelRef,
|
ref: labelRef,
|
||||||
className: styles['label-container'],
|
className: styles['label-container'],
|
||||||
children: open ?
|
children: open ?
|
||||||
<FocusLock className={classnames(styles['menu-container'], styles[`menu-direction-${typeof direction === 'string' ? direction : autoDirection}`])} autoFocus={false} lockProps={{ onMouseDown: menuOnMouseDown, onKeyUp: menuOnKeyUp }}>
|
<FocusLock className={classnames(styles['menu-container'], styles[`menu-direction-${typeof direction === 'string' ? direction : autoDirection}`])} autoFocus={true} lockProps={{ onMouseDown: menuOnMouseDown, onKeyUp: menuOnKeyUp }}>
|
||||||
{renderMenu()}
|
{renderMenu()}
|
||||||
</FocusLock>
|
</FocusLock>
|
||||||
:
|
:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue