Skip to content

Commit 242d7c4

Browse files
committed
Issue: #531
enter, shift enter
1 parent f423e65 commit 242d7c4

File tree

3 files changed

+20
-9
lines changed

3 files changed

+20
-9
lines changed

Diff for: src/main/components/editors/linked/UIEditorLinked.tsx

+7-5
Original file line numberDiff line numberDiff line change
@@ -275,8 +275,7 @@ export function getDisplayValue(
275275
dataProvider: string,
276276
dataTypeIdentifier?: DataTypeIdentifier,
277277
linkedColumnMetaData?: ColumnDescription,
278-
context?: AppContextType,
279-
) {
278+
context?: AppContextType) {
280279
if (value) {
281280
const index = linkReference.columnNames.findIndex(colName => colName === columnName);
282281
if (isDisplayRefColNameOrConcat) {
@@ -322,6 +321,8 @@ export function getDisplayValue(
322321
return ""
323322
};
324323

324+
325+
325326
/**
326327
* This component displays an input field with a button which provides a dropdownlist with values of a databook
327328
* when text is entered into the inputfield, the dropdownlist gets filtered
@@ -646,7 +647,7 @@ const UIEditorLinked: FC<IEditorLinked & IExtendableLinkedEditor & IComponentCon
646647
props.stopCellEditing(event);
647648
} else if (event.key === "Escape") {
648649
props.stopCellEditing(event)
649-
} else if(event.key === "Enter" && !linkedRef.current?.getOverlay().querySelector('.p-autocomplete-item.p-highlight')) {
650+
} else if(event.key === "Enter" && !linkedRef.current?.getOverlay()?.querySelector('.p-autocomplete-item.p-highlight')) {
650651
linkedRef.current?.hide();
651652
handleEnterKey(event, event.target, props.name, props.stopCellEditing);
652653
}
@@ -658,6 +659,7 @@ const UIEditorLinked: FC<IEditorLinked & IExtendableLinkedEditor & IComponentCon
658659
const index = Math.max(0, el ? parseInt(el.getAttribute("index") ?? "-1") : -1);
659660
handleSelect(suggestions[index]);
660661
}
662+
handleEnterKey(event, event.target, props.name, props.stopCellEditing);
661663
}
662664
}
663665
});
@@ -1020,10 +1022,10 @@ const UIEditorLinked: FC<IEditorLinked & IExtendableLinkedEditor & IComponentCon
10201022
}
10211023

10221024
// focus the input field when entering keys
1023-
useEventHandler(linkedInput.current && props.isCellEditor ? linkedInput.current : undefined, "keydown", () => {
1025+
useEventHandler(linkedInput.current && props.isCellEditor ? linkedInput.current : undefined, "keydown", (event: KeyboardEvent) => {
10241026
setTimeout(() => linkedInput.current.focus(), 0);
10251027
})
1026-
1028+
10271029
const handleDropdownClick = useCallback(() => {
10281030
if(linkedRef.current?.getOverlay()) {
10291031
linkedRef.current?.hide();

Diff for: src/main/util/html-util/GetFocusComponent.ts

+11-2
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,17 @@
2121
export function getFocusComponent(name:string, next:boolean):HTMLElement|undefined {
2222
//get all focusable elements, filter out negativ tabindex/disabled/td's sort by tabindex
2323
let focusable = Array.from(document.getElementById("reactUI-main")!.querySelectorAll("a, button, input, select, textarea, [tabindex], [contenteditable], #" + name)).filter((e: any) => {
24-
if (e.disabled || (e.getAttribute("tabindex") && parseInt(e.getAttribute("tabindex")) < 0) || e.tagName === "TD" || e.tagName === "TH" || e.classList.contains("designer-button") || e.classList.contains("navtable")) return false
25-
return true;
24+
if (e.disabled || (e instanceof HTMLInputElement && e.readOnly)
25+
|| (e.getAttribute("tabindex") && parseInt(e.getAttribute("tabindex")) < 0)
26+
|| e.tagName === "TD" || e.tagName === "TH"
27+
|| e.classList.contains("designer-button")
28+
|| e.classList.contains("navtable")) {
29+
return false;
30+
}
31+
else
32+
{
33+
return true;
34+
}
2635
}).sort((a: any, b: any) => {
2736
return (parseFloat(a.getAttribute("tabindex") || 99999) || 99999) - (parseFloat(b.getAttribute("tabindex") || 99999) || 99999);
2837
})

Diff for: src/main/util/other-util/HandleEnterKey.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ export function handleEnterKey(event:any, elem:any, name:string, stopEditing?:Fu
3030
}
3131
else {
3232
if (event.shiftKey) {
33-
getFocusComponent(name, false);
33+
getFocusComponent(name, false)?.focus();
3434
}
3535
else {
36-
getFocusComponent(name, true)
36+
getFocusComponent(name, true)?.focus();
3737
}
3838
}
3939
}

0 commit comments

Comments
 (0)