Commit 12991d93 authored by 邓超's avatar 邓超

fix: 修改规则焦点交互

parent 7c8e2d03
Pipeline #64620 passed with stages
......@@ -52,11 +52,16 @@ const RuleConfig = props => {
};
const insert = text => {
let rangeIndex = document.getElementById('ruleText').selectionStart;
// console.log(document.getElementById('ruleText').hasFocus());
setRule(`${rule.slice(0, rangeIndex)} ${text} ${rule.slice(rangeIndex)}`);
rangeIndex += text.toString().length;
ruleText.current.focus();
document.getElementById('ruleText').setSelectionRange(rangeIndex, rangeIndex); // 重新定位光标
if (rangeIndex > 0) {
// console.log(document.getElementById('ruleText').hasFocus());
setRule(`${rule.slice(0, rangeIndex)} ${text} ${rule.slice(rangeIndex)}`);
rangeIndex += text.toString().length;
ruleText.current.focus();
document.getElementById('ruleText').setSelectionRange(rangeIndex, rangeIndex); // 重新定位光标
} else {
setRule(`${rule} ${text}`);
ruleText.current.focus();
}
};
const insertFn = value => {
insert(value);
......
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