[ACS-8502] missing alignment for menu and search button (#10051)

This commit is contained in:
dominikiwanekhyland
2024-08-08 07:45:12 +02:00
committed by GitHub
parent d38e782fe3
commit 9a7ffe5e53
5 changed files with 88 additions and 102 deletions

View File

@@ -415,13 +415,13 @@ describe('SearchControlComponent', () => {
it('should have positive transform translation', () => { it('should have positive transform translation', () => {
userPreferencesService.setWithoutStore('textOrientation', 'ltr'); userPreferencesService.setWithoutStore('textOrientation', 'ltr');
fixture.detectChanges(); fixture.detectChanges();
expect(component.searchTextInput.subscriptAnimationState.params.transform).toBe('translateX(95%)'); expect(component.searchTextInput.subscriptAnimationState.params.transform).toBe('translateX(85%)');
}); });
it('should have negative transform translation ', () => { it('should have negative transform translation ', () => {
userPreferencesService.setWithoutStore('textOrientation', 'rtl'); userPreferencesService.setWithoutStore('textOrientation', 'rtl');
fixture.detectChanges(); fixture.detectChanges();
expect(component.searchTextInput.subscriptAnimationState.params.transform).toBe('translateX(-95%)'); expect(component.searchTextInput.subscriptAnimationState.params.transform).toBe('translateX(-85%)');
}); });
}); });
}); });

View File

@@ -25,11 +25,16 @@
flex: 0 0; flex: 0 0;
} }
/* stylelint-disable-next-line selector-class-pattern */
#{$mat-drawer-content} { #{$mat-drawer-content} {
@include flex-column; @include flex-column;
position: unset; position: unset;
overflow: auto; overflow: auto;
} }
.adf-layout-container-sidenav {
#{$mat-icon} {
vertical-align: sub;
}
}
} }

View File

@@ -1,32 +1,31 @@
@import 'styles/mat-selectors'; @import 'styles/mat-selectors';
.adf-search-container:has(.adf-input-form-field-divider) { .adf-search-container {
overflow: hidden; &:has(.adf-input-form-field-divider) {
} overflow: hidden;
.adf-search-button {
left: -13px;
}
[dir='rtl'] .adf-search-button {
right: -13px;
}
[dir='ltr'] .adf-search-button {
left: -13px;
}
.adf {
&-search-fixed-text {
line-height: normal;
} }
&-clear-search-button { #{$mat-form-field-subscript-wrapper} {
font-size: var(--theme-button-font-size); display: none;
cursor: pointer; }
.adf-search-container-transition {
display: flex;
align-items: center;
}
.adf {
&-search-fixed-text {
line-height: normal;
}
&-clear-search-button {
font-size: var(--theme-button-font-size);
cursor: pointer;
}
}
.adf-highlight {
color: var(--adf-theme-primary-900);
} }
} }
.adf-highlight {
color: var(--adf-theme-primary-900);
}

View File

@@ -65,7 +65,7 @@ describe('SearchTextInputComponent', () => {
component.expandable = false; component.expandable = false;
}); });
it('search button should be hide', () => { it('search button should be hidden', () => {
fixture.detectChanges(); fixture.detectChanges();
const searchButton: any = element.querySelector('#adf-search-button'); const searchButton: any = element.querySelector('#adf-search-button');
expect(searchButton).toBe(null); expect(searchButton).toBe(null);
@@ -79,12 +79,15 @@ describe('SearchTextInputComponent', () => {
}); });
describe('search button', () => { describe('search button', () => {
it('should NOT display a autocomplete list control when configured not to', fakeAsync(() => { let searchButton: DebugElement;
beforeEach(fakeAsync(() => {
fixture.detectChanges(); fixture.detectChanges();
tick(100); tick(100);
const searchButton: DebugElement = debugElement.query(By.css('#adf-search-button')); searchButton = debugElement.query(By.css('#adf-search-button'));
}));
it('should NOT display a autocomplete list control when configured not to', fakeAsync(() => {
component.subscriptAnimationState.value = 'active'; component.subscriptAnimationState.value = 'active';
fixture.detectChanges(); fixture.detectChanges();
@@ -104,11 +107,6 @@ describe('SearchTextInputComponent', () => {
})); }));
it('click on the search button should open the input box when is close', fakeAsync(() => { it('click on the search button should open the input box when is close', fakeAsync(() => {
fixture.detectChanges();
tick(100);
const searchButton: DebugElement = debugElement.query(By.css('#adf-search-button'));
searchButton.triggerEventHandler('click', null); searchButton.triggerEventHandler('click', null);
tick(100); tick(100);
@@ -121,11 +119,6 @@ describe('SearchTextInputComponent', () => {
})); }));
it('Search button should not change the input state too often', fakeAsync(() => { it('Search button should not change the input state too often', fakeAsync(() => {
fixture.detectChanges();
tick(100);
const searchButton: DebugElement = debugElement.query(By.css('#adf-search-button'));
component.subscriptAnimationState.value = 'active'; component.subscriptAnimationState.value = 'active';
fixture.detectChanges(); fixture.detectChanges();
@@ -150,10 +143,6 @@ describe('SearchTextInputComponent', () => {
})); }));
it('Search bar should close when user press ESC button', fakeAsync(() => { it('Search bar should close when user press ESC button', fakeAsync(() => {
fixture.detectChanges();
tick(100);
const inputDebugElement = debugElement.query(By.css('#adf-control-input')); const inputDebugElement = debugElement.query(By.css('#adf-control-input'));
component.subscriptAnimationState.value = 'active'; component.subscriptAnimationState.value = 'active';
fixture.detectChanges(); fixture.detectChanges();
@@ -179,66 +168,59 @@ describe('SearchTextInputComponent', () => {
fixture.detectChanges(); fixture.detectChanges();
}); });
/**
* function which finds Search Button and clicks it
*/
function clickSearchButton(): void {
fixture.detectChanges();
const searchButton: DebugElement = debugElement.query(By.css('#adf-search-button'));
searchButton.triggerEventHandler('click', null);
tick(100);
fixture.detectChanges();
tick(100);
}
/**
* Runs a test for ltr/rtl margin values
*
* @param isLtr sets ltr or rtl value to test
*/
function testMarginValue(isLtr: boolean): void {
userPreferencesService.setWithoutStore('textOrientation', isLtr ? 'ltr' : 'rtl');
clickSearchButton();
const expectedResult = isLtr ? { 'margin-left': 13 } : { 'margin-right': 13 };
expect(component.subscriptAnimationState.params).toEqual(expectedResult);
discardPeriodicTasks();
}
it('should have margin-left set when active and direction is ltr', fakeAsync(() => { it('should have margin-left set when active and direction is ltr', fakeAsync(() => {
userPreferencesService.setWithoutStore('textOrientation', 'ltr'); testMarginValue(true);
fixture.detectChanges();
const searchButton: DebugElement = debugElement.query(By.css('#adf-search-button'));
searchButton.triggerEventHandler('click', null);
tick(100);
fixture.detectChanges();
tick(100);
expect(component.subscriptAnimationState.params).toEqual({ 'margin-left': 13 });
discardPeriodicTasks();
}));
it('should have positive transform translateX set when inactive and direction is ltr', fakeAsync(() => {
userPreferencesService.setWithoutStore('textOrientation', 'ltr');
component.subscriptAnimationState.value = 'active';
fixture.detectChanges();
const searchButton: DebugElement = debugElement.query(By.css('#adf-search-button'));
searchButton.triggerEventHandler('click', null);
tick(100);
fixture.detectChanges();
tick(100);
expect(component.subscriptAnimationState.params).toEqual({ transform: 'translateX(95%)' });
discardPeriodicTasks();
})); }));
it('should have margin-right set when active and direction is rtl', fakeAsync(() => { it('should have margin-right set when active and direction is rtl', fakeAsync(() => {
userPreferencesService.setWithoutStore('textOrientation', 'rtl'); testMarginValue(false);
fixture.detectChanges(); }));
const searchButton: DebugElement = debugElement.query(By.css('#adf-search-button')); /**
* Runs a test for ltr/rtl transform values
searchButton.triggerEventHandler('click', null); *
tick(100); * @param isLtr sets ltr or rtl value to test
fixture.detectChanges(); */
tick(100); function testTransformValue(isLtr: boolean): void {
userPreferencesService.setWithoutStore('textOrientation', isLtr ? 'ltr' : 'rtl');
expect(component.subscriptAnimationState.params).toEqual({ 'margin-right': 13 }); component.subscriptAnimationState.value = 'active';
clickSearchButton();
const expectedValue = isLtr ? 'translateX(85%)' : 'translateX(-85%)';
expect(component.subscriptAnimationState.params).toEqual({ transform: expectedValue });
discardPeriodicTasks(); discardPeriodicTasks();
}
it('should have positive transform translateX set when inactive and direction is ltr', fakeAsync(() => {
testTransformValue(true);
})); }));
it('should have negative transform translateX set when inactive and direction is rtl', fakeAsync(() => { it('should have negative transform translateX set when inactive and direction is rtl', fakeAsync(() => {
userPreferencesService.setWithoutStore('textOrientation', 'rtl'); testTransformValue(false);
component.subscriptAnimationState.value = 'active';
fixture.detectChanges();
const searchButton: DebugElement = debugElement.query(By.css('#adf-search-button'));
searchButton.triggerEventHandler('click', null);
tick(100);
fixture.detectChanges();
tick(100);
expect(component.subscriptAnimationState.params).toEqual({ transform: 'translateX(-95%)' });
discardPeriodicTasks();
})); }));
it('should set browser autocomplete to on when configured', async () => { it('should set browser autocomplete to on when configured', async () => {

View File

@@ -143,11 +143,11 @@ export class SearchTextInputComponent implements OnInit, OnDestroy {
animationStates: SearchAnimationDirection = { animationStates: SearchAnimationDirection = {
ltr: { ltr: {
active: { value: 'active', params: { 'margin-left': 13 } }, active: { value: 'active', params: { 'margin-left': 13 } },
inactive: { value: 'inactive', params: { transform: 'translateX(95%)' } } inactive: { value: 'inactive', params: { transform: 'translateX(85%)' } }
}, },
rtl: { rtl: {
active: { value: 'active', params: { 'margin-right': 13 } }, active: { value: 'active', params: { 'margin-right': 13 } },
inactive: { value: 'inactive', params: { transform: 'translateX(-95%)' } } inactive: { value: 'inactive', params: { transform: 'translateX(-85%)' } }
} }
}; };
@@ -201,11 +201,11 @@ export class SearchTextInputComponent implements OnInit, OnDestroy {
if (this.dir === 'ltr') { if (this.dir === 'ltr') {
return this.subscriptAnimationState.value === 'inactive' return this.subscriptAnimationState.value === 'inactive'
? { value: 'active', params: { 'margin-left': 13 } } ? { value: 'active', params: { 'margin-left': 13 } }
: { value: 'inactive', params: { transform: 'translateX(95%)' } }; : { value: 'inactive', params: { transform: 'translateX(85%)' } };
} else { } else {
return this.subscriptAnimationState.value === 'inactive' return this.subscriptAnimationState.value === 'inactive'
? { value: 'active', params: { 'margin-right': 13 } } ? { value: 'active', params: { 'margin-right': 13 } }
: { value: 'inactive', params: { transform: 'translateX(-95%)' } }; : { value: 'inactive', params: { transform: 'translateX(-85%)' } };
} }
} }