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

MARP-992: Custom dropdown should be scrollable #124

Merged
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 @@ -3,6 +3,12 @@
}

.dropdown-menu {
max-height: 27.5rem;
overflow: auto;
@media (max-width: 990px) {
max-height: 13.75rem;
}

.dropdown-item {
&.active {
background-color: var(--ivy-textarea-background-color);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ import { ComponentFixture, TestBed } from '@angular/core/testing';
import { CommonDropdownComponent } from './common-dropdown.component';
import { By } from '@angular/platform-browser';
import { TranslateModule, TranslateService } from '@ngx-translate/core';
import { Viewport } from 'karma-viewport/dist/adapter/viewport';
import { ItemDropdown } from '../../models/item-dropdown.model';
import { ElementRef } from '@angular/core';

declare const viewport: Viewport;
describe('CommonDropdownComponent', () => {
let component: CommonDropdownComponent<string>;
let fixture: ComponentFixture<CommonDropdownComponent<string>>;
Expand Down Expand Up @@ -87,4 +89,34 @@ describe('CommonDropdownComponent', () => {
expect(result).toBeTrue();
expect(translateService.instant).toHaveBeenCalledWith('originalLabel');
});

it('should apply scrollbar when dropdown is opened and items overflow', () => {
viewport.set(1920);

component.isDropdownOpen = true;
fixture.detectChanges();

const dropdownMenu = fixture.debugElement.query(By.css('.dropdown-menu')).nativeElement;

const maxHeight = getComputedStyle(dropdownMenu).maxHeight;
const overflow = getComputedStyle(dropdownMenu).overflow;

expect(maxHeight).toBe('440px');
expect(overflow).toBe('auto');
});

it('should apply scrollbar when dropdown is opened in smaller screen', () => {
viewport.set(430);

component.isDropdownOpen = true;
fixture.detectChanges();

const dropdownMenu = fixture.debugElement.query(By.css('.dropdown-menu')).nativeElement;

const maxHeight = getComputedStyle(dropdownMenu).maxHeight;
const overflow = getComputedStyle(dropdownMenu).overflow;

expect(maxHeight).toBe('220px');
expect(overflow).toBe('auto');
});
});
Loading