Skip to content

Commit

Permalink
fix: focus border color issue
Browse files Browse the repository at this point in the history
  • Loading branch information
dineug committed Dec 1, 2023
1 parent a96c8a9 commit 3bc7d73
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@ export const root = css`
div[data-focus-border] {
border-color: var(--placeholder) !important;
}
div[data-focus-border-bottom],
div[data-focus-border-bottom] {
border-bottom-color: var(--placeholder) !important;
}
input[data-focus-border-bottom] {
border-bottom-color: var(--placeholder) !important;
}
Expand Down
13 changes: 11 additions & 2 deletions packages/erd-editor/src/components/erd-editor/ErdEditor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,21 @@ const ErdEditor: FC<ErdEditorProps, ErdEditorElement> = (props, ctx) => {
keydown$.next(event);
};

let currentFocus = false;
let timerId = -1;

const handleFocus = () => {
currentFocus = true;
state.isFocus = true;
};

const handleFocusout = (event: FocusEvent) => {
state.isFocus = false;
const handleFocusout = () => {
currentFocus = false;

window.clearTimeout(timerId);
timerId = window.setTimeout(() => {
state.isFocus = currentFocus;
}, 10);
};

onMounted(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,8 @@ const ColumnDataType: FC<ColumnDataTypeProps> = (props, ctx) => {
};

const handleFocusout = (event: FocusEvent) => {
if (!props.edit) return;

currentFocus = false;

window.clearTimeout(timerId);
Expand Down

0 comments on commit 3bc7d73

Please sign in to comment.