Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
"dependencies": {
"@carbon/icons-react": "^11.67.0",
"@dnd-kit/core": "^6.1.0",
"@kaoto/forms": "^1.5.9",
"@kaoto/forms": "^1.6.0",
"@kie-tools-core/editor": "^10.0.0",
"@kie-tools-core/notifications": "^10.0.0",
"@visx/shape": "^3.12.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { FieldProps, FieldWrapper, SchemaContext, Typeahead, useFieldValue } from '@kaoto/forms';
import { Button, InputGroup, InputGroupItem } from '@patternfly/react-core';
import { FunctionComponent, useContext, useEffect, useRef, useState } from 'react';
import { FunctionComponent, useContext, useEffect, useState } from 'react';

import { EntitiesContext } from '../../../../../providers/entities.provider';
import { VisibleFlowsContext } from '../../../../../providers/visible-flows.provider';
Expand All @@ -12,29 +12,11 @@ export const DirectEndpointNameField: FunctionComponent<FieldProps> = ({ propNam
const entitiesContext = useContext(EntitiesContext);
const visibleFlowsContext = useContext(VisibleFlowsContext);
const [typedInputValue, setTypedInputValue] = useState(value);
const typeaheadWrapperRef = useRef<HTMLDivElement>(null);

useEffect(() => {
setTypedInputValue(value);
}, [value]);

useEffect(() => {
const inputElement = typeaheadWrapperRef.current?.querySelector('input');
if (!inputElement) {
return;
}

const onInput = (event: Event) => {
setTypedInputValue((event.target as HTMLInputElement).value);
};

inputElement.addEventListener('input', onInput);

return () => {
inputElement.removeEventListener('input', onInput);
};
}, []);

const { existingDirectNames, items, selectedItem, typedName, onTypeaheadChange, onCleanInput, onCreateOption } =
useDirectEndpointNameOptions({
value,
Expand Down Expand Up @@ -62,31 +44,30 @@ export const DirectEndpointNameField: FunctionComponent<FieldProps> = ({ propNam
>
<InputGroup>
<InputGroupItem isFill>
<div ref={typeaheadWrapperRef}>
<Typeahead
aria-label={schema.title ?? propName}
data-testid={propName}
selectedItem={selectedItem}
items={items}
placeholder={schema.default?.toString()}
id={propName}
onChange={(item) => {
onTypeaheadChange(item);
setTypedInputValue(item?.name ?? '');
}}
onCleanInput={() => {
onCleanInput();
setTypedInputValue('');
}}
onCreate={(createItemValue, filterValue) => {
onCreateOption(createItemValue, filterValue);
setTypedInputValue(filterValue ?? '');
}}
onCreatePrefix="direct endpoint"
disabled={disabled}
allowCustomInput
/>
</div>
<Typeahead
aria-label={schema.title ?? propName}
data-testid={propName}
selectedItem={selectedItem}
items={items}
placeholder={schema.default?.toString()}
id={propName}
onChange={(item) => {
onTypeaheadChange(item);
setTypedInputValue(item?.name ?? '');
}}
onCleanInput={() => {
onCleanInput();
setTypedInputValue('');
}}
onCreate={(createItemValue, filterValue) => {
onCreateOption(createItemValue, filterValue);
setTypedInputValue(filterValue ?? '');
}}
onInputValueChange={setTypedInputValue}
onCreatePrefix="direct endpoint"
disabled={disabled}
allowCustomInput
/>
</InputGroupItem>
<InputGroupItem>
<Button variant="secondary" onClick={onCreateRoute} isDisabled={!canCreateRoute}>
Expand Down
20 changes: 19 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3198,6 +3198,24 @@ __metadata:
languageName: node
linkType: hard

"@kaoto/forms@npm:^1.6.0":
version: 1.6.0
resolution: "@kaoto/forms@npm:1.6.0"
dependencies:
ajv: "npm:^8.12.0"
clsx: "npm:^2.1.0"
lodash.clonedeep: "npm:^4.5.0"
usehooks-ts: "npm:^3.0.0"
peerDependencies:
"@patternfly/patternfly": 6.4.0
"@patternfly/react-core": 6.4.0
"@patternfly/react-icons": 6.4.0
react: ^18.3.1
react-dom: ^18.3.1
checksum: 10/8c8b30daca3bb4b59b314805eb2c5ddb7835119370eb9e4e616bfb8da8470e930c003cd25a610bb223a3b5c48ecc9259dffc8d11a810b249ad2b77cdeac0c175
languageName: node
linkType: hard

"@kaoto/kaoto-tests@workspace:packages/ui-tests":
version: 0.0.0-use.local
resolution: "@kaoto/kaoto-tests@workspace:packages/ui-tests"
Expand Down Expand Up @@ -3265,7 +3283,7 @@ __metadata:
"@dnd-kit/core": "npm:^6.1.0"
"@eslint/js": "npm:^9.10.0"
"@kaoto/camel-catalog": "npm:^0.3.1"
"@kaoto/forms": "npm:^1.5.9"
"@kaoto/forms": "npm:^1.6.0"
"@kie-tools-core/editor": "npm:^10.0.0"
"@kie-tools-core/notifications": "npm:^10.0.0"
"@patternfly/patternfly": "npm:^6.4.0"
Expand Down