Commit 83bf3907 authored by LAVENIER's avatar LAVENIER
Browse files

Release v0.11.12

[fix] Autocomplete: use blur instead of focusout event
parent 2536783d
{
"name": "@sumaris-net/ngx-components",
"description": "SUMARiS Angular components",
"version": "0.11.10",
"version": "0.11.12",
"author": "contact@e-is.pro",
"license": "AGPL-3.0",
"readmeFilename": "README.md",
......
......@@ -6,15 +6,27 @@ import {isNil, isNilOrBlank, isNotEmptyArray, isNotNil, toBoolean, toNumber} fro
export function selectInputContent(event: UIEvent) {
if (event.defaultPrevented) return false;
const input = (event.target as any);
if (input && typeof input.select === 'function') {
if (!input) return true;
// Nothing to select
if (isNilOrBlank(input.value)) return false;
// Nothing to select
if (isNilOrBlank(input.value)) return false;
if (typeof input.selectRange === 'function') {
try {
input.selectRange(input.value.length, 0);
return true;
} catch (err) {
console.error('Could not select input content, using selectRange()', err);
return false;
}
}
if (input && typeof input.select === 'function') {
try {
input.select();
return true;
} catch (err) {
console.error('Could not select input content', err);
console.error('Could not select input content, using select()', err);
return false;
}
}
......
......@@ -92,9 +92,8 @@
[readonly]="readonly"
[required]="required"
(click)="onClick.emit($event)"
(blur)="onBlur.emit($event)"
(focusin)="filterInputTextFocusInEvent($event)"
(focusout)="filterInputTextFocusOutEvent($event)"
(focus)="filterInputTextFocusInEvent($event)"
(blur)="filterInputTextBlurEvent($event)"
(keyup.arrowdown)="!autoComplete.showPanel && onDropButtonClick.emit($event)">
<!-- autocomplete -->
......
......@@ -604,7 +604,7 @@ export class MatAutocompleteField implements OnInit, InputElement, OnDestroy, Co
return false;
}
filterInputTextFocusOutEvent(event: FocusEvent) {
filterInputTextBlurEvent(event: FocusEvent) {
if (!event || event.defaultPrevented) return;
// Ignore event from mat-option
......@@ -612,16 +612,17 @@ export class MatAutocompleteField implements OnInit, InputElement, OnDestroy, Co
event.preventDefault();
if (event.stopPropagation) event.stopPropagation();
event.returnValue = false;
//DEBUG console.debug(this.logPrefix + " Cancelling focus event");
//DEBUG console.debug(this.logPrefix + " Cancelling blur event");
return false;
}
//DEBUG
//console.debug(this.logPrefix + ' Focus out: move caret to the beginning');
//console.debug(this.logPrefix + ' Blur: move caret to the beginning');
// Move caret to the beginning (fix issue IMAGINE-469)
selectInputRange(event.target as any, 0, 0);
this.onBlur.emit(event);
return true;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment