Commit 62249dc2 authored by zhangwenshuai's avatar zhangwenshuai

update data- param

parent db1fcf46
......@@ -201,15 +201,15 @@ const Cell = (props: CellProps) => {
// 获取当前节点的选中状态
const dom = cellUnit.current;
let selected = false;
if (dom && dom.getAttribute('data-selectedCell')) {
selected = dom.getAttribute('data-selectedCell') === '1';
if (dom && dom.getAttribute('data-selected-cell')) {
selected = dom.getAttribute('data-selected-cell') === '1';
}
if (selected) {
// 当前已选中,则进入编辑状态
setStatus('edit');
if (dom) {
// 给当前dom添加编辑状态
dom.setAttribute('data-editingCell', '1');
dom.setAttribute('data-editing-cell', '1');
}
} else {
// 否则进入选中状态
......@@ -218,12 +218,12 @@ const Cell = (props: CellProps) => {
const doms = document.querySelectorAll('.cellUnit');
if (doms) {
doms.forEach((item) => {
item.setAttribute('data-selectedCell', '0');
item.setAttribute('data-selected-cell', '0');
item.classList.remove(s.selected);
});
}
// 给当前dom添加选中状态
dom.setAttribute('data-selectedCell', '1');
dom.setAttribute('data-selected-cell', '1');
// 给当前dom添加选中样式
dom.classList.add(s.selected);
}
......@@ -346,8 +346,8 @@ const Cell = (props: CellProps) => {
className={classNames('cellUnit', `row_${rowIndex}`, `col_${columnIndex}`, cellClassName)}
style={cellStyle}
id={`cellUnit_${rowIndex}_${columnIndex}`}
data-selectedCell="0"
data-editingCell="0"
data-selected-cell="0"
data-editing-cell="0"
onMouseEnter={onMouseEnter}
onMouseLeave={onMouseLeave}
ref={cellUnit}
......
......@@ -32,7 +32,7 @@ export default function CellContainer<P extends Props>(Comp) {
onBlur = (e: any) => {
let currTarget = e.target;
while (currTarget != document) {
let editing = currTarget.getAttribute('data-editingCell');
let editing = currTarget.getAttribute('data-editing-cell');
// 当前点击div是正在编辑的cell时,阻止修改回调
if (editing === '1') {
return;
......@@ -48,7 +48,7 @@ export default function CellContainer<P extends Props>(Comp) {
const doms = document.querySelectorAll('.cellUnit');
if (doms) {
doms.forEach((item) => {
item.setAttribute('data-editingCell', '0');
item.setAttribute('data-editing-cell', '0');
});
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment