Improved channel focus

master
WolverinDEV 2021-03-23 16:02:16 +01:00
parent 5cf7730b7a
commit 0dd62df664
1 changed files with 10 additions and 2 deletions

View File

@ -25,7 +25,9 @@ const ContainerView = (props: { tree: RDPChannelTree, events: Registry<ChannelTr
let target = event.target as HTMLElement; let target = event.target as HTMLElement;
while(target !== refContainer.current && target) { target = target.parentElement; } while(target !== refContainer.current && target) { target = target.parentElement; }
focusWithin.current = !!target; if(focusWithin.current) {
refContainer.current?.focus();
}
}); });
let keyListener; let keyListener;
@ -55,7 +57,13 @@ const ContainerView = (props: { tree: RDPChannelTree, events: Registry<ChannelTr
}); });
return ( return (
<div className={viewStyle.treeContainer} ref={refContainer}> <div
className={viewStyle.treeContainer}
ref={refContainer}
onBlur={() => focusWithin.current = false}
onFocus={() => focusWithin.current = true}
tabIndex={1}
>
<ChannelTreeView events={props.events} dataProvider={props.tree} ref={props.tree.refTree} /> <ChannelTreeView events={props.events} dataProvider={props.tree} ref={props.tree.refTree} />
<PopoutButton tree={props.tree} ref={props.tree.refPopoutButton} /> <PopoutButton tree={props.tree} ref={props.tree.refPopoutButton} />
</div> </div>