fix: handling blur,focus for the containers to start tabbing and using arrow keys

This commit is contained in:
Kevin
2025-06-18 08:28:09 -05:00
parent 06f0276569
commit f1d9380146
2 changed files with 18 additions and 1 deletions

View File

@ -361,11 +361,24 @@ export const ProjectExplorer = ({
break
}
}
const handleFocus = () => {
setActiveIndex(CONTAINER_IS_SELECTED)
}
const handleBlur = () => {
setActiveIndex(NOTHING_IS_SELECTED)
}
document.addEventListener('keydown', keyDownHandler)
document.addEventListener('click', handleClickOutside)
fileExplorerContainer.current?.addEventListener('focus', handleFocus)
fileExplorerContainer.current?.addEventListener('blur', handleBlur)
return () => {
document.removeEventListener('click', handleClickOutside)
document.removeEventListener('keydown', keyDownHandler)
fileExplorerContainer.current?.removeEventListener('focus', handleFocus)
fileExplorerContainer.current?.addEventListener('blur', handleBlur)
}
}, [])

View File

@ -414,7 +414,11 @@ const Home = () => {
</ul>
</aside>
<section data-testid="file-explorer-section" className="flex flex-row justify-between" style={{width:'850px'}}>
<section
data-testid="file-explorer-section"
className="flex flex-row justify-between"
style={{ width: '850px' }}
>
<ProjectExplorer project={kclSamples}></ProjectExplorer>
<ProjectExplorer project={kclSamples}></ProjectExplorer>
<ProjectExplorer project={kclSamples1}></ProjectExplorer>