Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(core): enable input field to remain active on mouse selection of the entered text #51

Merged
merged 3 commits into from
Feb 15, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -165,13 +165,17 @@
let-nodeWithInput="nodeWithInput"
let-hide="hide"
>
<div (document:click)="hide()">
<div (document:click)="handleDocumentClick($event)">
<input
type="text"
class="text-input"
autofocus
value="{{ input.setValueName(nodeWithInput.node.state) }}"
(focusout)="callback($event.target)"
(mousedown)="handleMouseDown($event)"
(mouseup)="handleMouseUp()"
(mouseleave)="handleMouseLeave($event)"
placeholder="Enter the text here"
/>
</div>
</ng-template>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export class GroupComponent<E> implements OnInit, AfterViewInit {
private readonly localizationSvc: LocalizationProviderService,
) {}
public inputType = InputTypes;

private isMouseDown: boolean = false;
@Input()
group: AbstractBaseGroup<E>;

Expand Down Expand Up @@ -568,6 +568,27 @@ export class GroupComponent<E> implements OnInit, AfterViewInit {
return;
}

handleMouseDown(event: MouseEvent): void {
this.isMouseDown = true;
}

handleMouseUp(): void {
this.isMouseDown = false;
}

handleMouseLeave(event: MouseEvent): void {
this.isMouseDown = false;
}

handleDocumentClick(event: MouseEvent): void {
const target = event.target as HTMLElement;

// Check if the click is outside the input element and not part of a drag
if (!this.isMouseDown) {
// If not a drag and click outside the input, hide the input box
this.hidePopper();
}
}
/**
* It removes all the inputs that come after the current input
* @param element - NodeWithInput<E>
Expand Down
2 changes: 1 addition & 1 deletion projects/workflows-element/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@
"access": "public",
"directory": "dist"
},
"hash": "388809af6444a8fc997fa5e1e76c0f7847b34244a3cb68d956706dec8c470733"
"hash": "04a0e776afc8afd96f827f3e10f8c4ae642720bd7f79d9dcc9ca4552b9295eb2"
}
Loading