Skip to content

Commit

Permalink
add type prop to autocomplete component to pass file path
Browse files Browse the repository at this point in the history
  • Loading branch information
MahmoudHamdy02 committed Jul 18, 2023
1 parent 6d859da commit c41f31c
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pkg/lib/cockpit-components-file-autocomplete.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,12 @@ export class FileAutoComplete extends React.Component {
displayFiles: [],
isOpen: false,
value: this.props.value || null,
type: this.props.type
};
this.updateFiles(props.value || '/');
if (this.props.type === "file") {
this.props.onChange(this.props.value.slice(this.props.value.lastIndexOf("/") + 1));
}
this.updateFiles(props.value ? this.props.type === "file" ? props.value.slice(0, props.value.lastIndexOf("/") + 1) : props.value : "/");
this.typeaheadInputValue = "";
this.allowFilesUpdate = true;
this.updateFiles = this.updateFiles.bind(this);
Expand Down

0 comments on commit c41f31c

Please sign in to comment.