fix statusline board error

This commit is contained in:
musistudio
2025-12-26 13:48:05 +08:00
parent dba5116069
commit 983297b781

View File

@@ -739,9 +739,19 @@ export function StatusLineConfigDialog({
// 检查是否按下了删除键 (Delete 或 Backspace) // 检查是否按下了删除键 (Delete 或 Backspace)
if (e.key === 'Delete' || e.key === 'Backspace') { if (e.key === 'Delete' || e.key === 'Backspace') {
// 检查当前焦点元素是否是预览区域的模块
const activeElement = document.activeElement as HTMLElement;
// 检查焦点元素是否是预览区域的模块(有 cursor-pointer 类和 tabIndex
const isPreviewModule = activeElement?.classList.contains('cursor-pointer') &&
activeElement?.hasAttribute('tabIndex');
// 只有当焦点在预览区域的组件上时,才执行删除操作
if (isPreviewModule) {
e.preventDefault(); e.preventDefault();
deleteSelectedModule(); deleteSelectedModule();
} }
}
}; };
// 添加事件监听器 // 添加事件监听器
@@ -953,6 +963,7 @@ export function StatusLineConfigDialog({
{currentModules.map((module, index) => ( {currentModules.map((module, index) => (
<div <div
key={index} key={index}
tabIndex={0}
className={`cursor-pointer ${ className={`cursor-pointer ${
selectedModuleIndex === index selectedModuleIndex === index
? "bg-white/20" ? "bg-white/20"