Skip to content
This repository was archived by the owner on Jul 28, 2025. It is now read-only.

Commit 066c13f

Browse files
committed
fixed
1 parent f8fe0d2 commit 066c13f

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

src/components/HeaderMenu.tsx

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,18 @@ const HeaderMenu = (headerMenuProps: HeaderMenuProps) => {
269269
strategy: "fixed",
270270
});
271271

272-
function persistLabelChange(newKey: string) {
272+
function persistLabelChange() {
273+
// trim label will get a valid yaml key
274+
const newKey = dbTrim(labelState);
275+
// Check if key already exists. If so, mark it as invalid
276+
if (
277+
headerMenuProps.headerProps.allColumns.find(
278+
(o: Column) => o.id === newKey
279+
)
280+
) {
281+
setLabelStateInvalid(true);
282+
return;
283+
}
273284
const futureOrder = headerMenuProps.headerProps.allColumns.map(
274285
(o: Column) => (o.id === column.id ? newKey : o.id)
275286
);
@@ -294,18 +305,7 @@ const HeaderMenu = (headerMenuProps: HeaderMenuProps) => {
294305
}
295306
function handleKeyDown(e: any) {
296307
if (e.key === "Enter") {
297-
// trim label will get a valid yaml key
298-
const newKey = dbTrim(labelState);
299-
// Check if key already exists. If so, mark it as invalid
300-
if (
301-
headerMenuProps.headerProps.allColumns.find(
302-
(o: Column) => o.id === newKey
303-
)
304-
) {
305-
setLabelStateInvalid(true);
306-
return;
307-
}
308-
persistLabelChange(newKey);
308+
persistLabelChange();
309309
}
310310
}
311311

@@ -322,6 +322,7 @@ const HeaderMenu = (headerMenuProps: HeaderMenuProps) => {
322322
*/
323323
function handleBlur(e: any) {
324324
e.preventDefault();
325+
persistLabelChange();
325326
}
326327

327328
function adjustWidthOfTheColumnsWhenAdd(wantedPosition: number) {

0 commit comments

Comments
 (0)