[ACS-9374][ACS-9590] Prevent search popup flicker on Enter key press and infinite loading animation (#4683)

* [ACS-9374] Prevent search popup flicker on Enter key press

* feat: WIP - fixing search input errors for draft PR

* Add test for mat-error on empty search term and handle loading state properly

* Add test for mat-error on empty search term and handle loading state properly

* Add whitespace error and fix unit test for checkbox

* Fix sonarcloud issue for exception

* [ACS-9374] Add validator to aca-shared

* [ACS-9374] Simplify HTML by handling error state in TypeScript

* [ACS-9374] Fix error validation process

* [ACS-9374] Fix sonarcloud issue

* [ACS-9374] Prevent library search with search term less than 2 characters

* [ACS-9374] Show validation error on checking and unchecking checkbox

* [ACS-9374] Provide default value to hasLibrariesConstraint

* [ACS-9374] Close dropdown on search submission
This commit is contained in:
Shivangi Shree
2025-07-30 05:24:55 -04:00
committed by GitHub
parent d76d7590d6
commit c493824778
11 changed files with 365 additions and 35 deletions
@@ -0,0 +1,50 @@
/*!
* Copyright © 2005-2025 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* Alfresco Example Content Application
*
* This file is part of the Alfresco Example Content Application.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* from Hyland Software. If not, see <http://www.gnu.org/licenses/>.
*/
import { FormControl } from '@angular/forms';
import { noWhitespaceValidator } from './no-whitespace.validator';
describe('noWhitespaceValidator', () => {
const validatorFn = noWhitespaceValidator();
it('should return null for valid non-whitespace input', () => {
const control = new FormControl('valid input');
expect(validatorFn(control)).toBeNull();
});
it('should return error for input with only spaces', () => {
const control = new FormControl(' ');
expect(validatorFn(control)).toEqual({ whitespace: true });
});
it('should return error for empty string', () => {
const control = new FormControl('');
expect(validatorFn(control)).toBeNull();
});
it('should return null for input with leading and trailing spaces but valid content inside', () => {
const control = new FormControl(' valid ');
expect(validatorFn(control)).toBeNull();
});
});
@@ -0,0 +1,37 @@
/*!
* Copyright © 2005-2025 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* Alfresco Example Content Application
*
* This file is part of the Alfresco Example Content Application.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* from Hyland Software. If not, see <http://www.gnu.org/licenses/>.
*/
import { AbstractControl, ValidationErrors, ValidatorFn } from '@angular/forms';
export const noWhitespaceValidator = (): ValidatorFn => {
return (control: AbstractControl): ValidationErrors | null => {
const rawValue = control.value;
if (!rawValue) {
return null;
}
const trimmedValue = rawValue.toString().trim();
return trimmedValue.length === 0 ? { whitespace: true } : null;
};
};
+5 -1
View File
@@ -40,6 +40,7 @@ export * from './lib/components/document-base-page/document-base-page.component'
export * from './lib/components/document-base-page/document-base-page.service';
export * from './lib/components/open-in-app/open-in-app.component';
export * from './lib/constants';
export * from './lib/directives/contextmenu/contextmenu.directive';
export * from './lib/directives/pagination.directive';
@@ -60,5 +61,8 @@ export * from './lib/services/app-settings.service';
export * from './lib/services/user-profile.service';
export * from './lib/services/navigation-history.service';
export * from './lib/utils/node.utils';
export * from './lib/testing/lib-testing-module';
export * from './lib/utils/node.utils';
export * from './lib/validators/no-whitespace.validator';