Skip to content

Commit

Permalink
Additional fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
rubenthoms committed Sep 19, 2023
1 parent 5d99bcc commit 7e9626e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,12 @@ export class Suggestions extends React.Component<SuggestionsProps> {

componentDidUpdate(previousProps: SuggestionsProps): void {
const { visible, treeNodeSelection, suggestionsRef } = this.props;
if (previousProps.visible != visible || previousProps.treeNodeSelection != treeNodeSelection) {
if (previousProps.visible !== visible || previousProps.treeNodeSelection !== treeNodeSelection) {
if (this.props.treeNodeSelection) {
this._allOptions = this.props.treeNodeSelection.getSuggestions();
this._currentNodeLevel = this.props.treeNodeSelection.getFocussedLevel();
}

this._upperSpacerHeight = 0;
if (suggestionsRef.current) {
(suggestionsRef.current as HTMLDivElement).scrollTop = 0;
Expand Down Expand Up @@ -144,7 +149,7 @@ export class Suggestions extends React.Component<SuggestionsProps> {
}

private handleGlobalKeyDown(e: globalThis.KeyboardEvent): void {
const { visible } = this.props;
const { visible, treeNodeSelection } = this.props;
if (visible) {
if (e.key === "ArrowUp") {
this.markSuggestionAsHoveredAndMakeVisible(Math.max(0, this._currentlySelectedSuggestionIndex - 1));
Expand All @@ -153,7 +158,7 @@ export class Suggestions extends React.Component<SuggestionsProps> {
Math.min(this._allOptions.length - 1, this._currentlySelectedSuggestionIndex + 1)
);
}
if (e.key == "Enter" && this.currentlySelectedSuggestion() !== undefined) {
if (e.key == "Enter" && this.currentlySelectedSuggestion() !== undefined && this._allOptions.length > 0 && !treeNodeSelection?.focussedNodeNameContainsWildcard()) {
this.useSuggestion(e, this.currentlySelectedSuggestion().getAttribute("data-use") as string);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,10 +236,6 @@ export class SmartNodeSelectorComponent extends React.Component<SmartNodeSelecto
}

componentDidUpdate(prevProps: SmartNodeSelectorProps): void {
if (this.updateFromWithin) {
this.updateFromWithin = false;
return;
}
if (
(this.props.data && JSON.stringify(this.props.data) !== JSON.stringify(prevProps.data)) ||
(this.props.delimiter && this.props.delimiter !== prevProps.delimiter)
Expand Down Expand Up @@ -612,12 +608,15 @@ export class SmartNodeSelectorComponent extends React.Component<SmartNodeSelecto
const domNode = (this.tagFieldRef as React.RefObject<HTMLUListElement>).current as HTMLUListElement;
const suggestions = (this.suggestionsRef as React.RefObject<HTMLDivElement>).current as HTMLDivElement;
const eventTarget = event.target as Element;
if (domNode && domNode.getBoundingClientRect().width === 0) {
return;
}
if ((!domNode || !domNode.contains(eventTarget)) && (!suggestions || !suggestions.contains(eventTarget))) {
this.noUserInputSelect = false;
this.hideSuggestions({
callback: () => {
if (!this.selectionHasStarted) {
this.unselectAllTags({});

this.updateState({ currentTagIndex: -1 });
}
this.selectionHasStarted = false;
Expand Down
5 changes: 0 additions & 5 deletions frontend/src/lib/components/VectorSelector/vectorSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,6 @@ export class VectorSelectorComponent extends SmartNodeSelectorComponent {
}

componentDidUpdate(prevProps: VectorSelectorProps): void {
if (this.updateFromWithin) {
this.updateFromWithin = false;
return;
}

if (
this.props.customVectorDefinitions &&
JSON.stringify(this.props.customVectorDefinitions) !== JSON.stringify(prevProps.customVectorDefinitions)
Expand Down

0 comments on commit 7e9626e

Please sign in to comment.