diff --git a/CHANGELOG.md b/CHANGELOG.md
index 5e4de956..57e5ff69 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,34 @@
+## 2.3.0 (27.06.2022)
+
+### Fixes and improvements
+
+- [Sidenav](https://mdbootstrap.com/docs/b5/angular/navigation/sidenav/)
+ - Resolved problems with arrow position updates in slim mode and accordion mode
+ - Resolved problem with initialization of component with `[right]="true"` and `[hidden]="false"` options
+ - Fixed problem with long content display in component with `[right]="true"` option
+- Fixed problems with long label positioning in [checkbox](https://mdbootstrap.com/docs/b5/angular/forms/checkbox/), [switch](https://mdbootstrap.com/docs/b5/angular/forms/switch/) and [radio](https://mdbootstrap.com/docs/b5/angular/forms/radio/)
+- Resolved problem with multiple `paginationChange` events emitted on [datatable](https://mdbootstrap.com/docs/b5/angular/data/datatables/) initialization
+- Resolved problems with [pagination](https://mdbootstrap.com/docs/b5/angular/navigation/pagination/) and [accordion](https://mdbootstrap.com/docs/b5/angular/components/accordion/) styles when using [theme](https://mdbootstrap.com/docs/b5/angular/content-styles/theme/)
+- Fixed problem with max file quantity in [file upload](https://mdbootstrap.com/docs/b5/angular/plugins/file-upload/) plugin with `multiple` mode
+- Resolved problem with first option highlight in [select](https://mdbootstrap.com/docs/b5/angular/forms/select/) with a `[highlightFirst]="false"` option
+- Added `type="button"` to the 'insert horizontal line' button in [WYSIWYG](https://mdbootstrap.com/docs/b5/angular/plugins/wysiwyg-editor/) to resolve problem with form submit
+- Zero-length [tooltip](https://mdbootstrap.com/docs/b5/angular/components/tooltips/) and [popover](https://mdbootstrap.com/docs/b5/angular/components/popovers/) will no longer be displayed
+- Fixed problem with multiple `(selected)` events emitted after click on [autocomplete](https://mdbootstrap.com/docs/b5/angular/forms/autocomplete/) option
+
+### New
+
+- Addew new [onboarding plugin](https://mdbootstrap.com/docs/b5/angular/plugins/onboarding/)
+- [Stepper](https://mdbootstrap.com/docs/b5/angular/components/stepper/)
+ - Added possibility to block step navigation on step header click
+ - Added possibility to edit buttons and header text in mobile mode
+- Added new `--mdb-bg-opacity` CSS variable
+- Added optional auto select on tab-out in [select](https://mdbootstrap.com/docs/b5/angular/forms/select/) and [autocomplete](https://mdbootstrap.com/docs/b5/angular/forms/autocomplete/)
+- Added list group new variant with `.list-group-light` class
+- Added `.table-group-divider` and `.table-divider-color` classes to emphasize the separation of thead from tbody
+- Added new `.divider-horizontal`, `.divider-vertical`, `.divider-horizontal-blurry` and `.divider-vertical-blurry` classes
+
+---
+
## 2.2.0 (16.05.2022)
### Fixes and improvements:
diff --git a/README.txt b/README.txt
index ad4535c7..a24a232a 100644
--- a/README.txt
+++ b/README.txt
@@ -1,6 +1,6 @@
MDB 5 Angular
-Version: FREE 2.2.0
+Version: FREE 2.3.0
Documentation:
https://mdbootstrap.com/docs/b5/angular/
diff --git a/package-lock.json b/package-lock.json
index 1df28f71..0faf05b7 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "mdb-angular-ui-kit-free",
- "version": "2.1.0",
+ "version": "2.2.0",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "mdb-angular-ui-kit-free",
- "version": "2.1.0",
+ "version": "2.2.0",
"dependencies": {
"@angular/animations": "~13.2.4",
"@angular/cdk": "^13.2.4",
diff --git a/package.json b/package.json
index 97542d95..feeb0993 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "mdb-angular-ui-kit-free",
- "version": "2.2.0",
+ "version": "2.3.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
diff --git a/projects/mdb-angular-ui-kit/CHANGELOG.md b/projects/mdb-angular-ui-kit/CHANGELOG.md
index 5e4de956..57e5ff69 100644
--- a/projects/mdb-angular-ui-kit/CHANGELOG.md
+++ b/projects/mdb-angular-ui-kit/CHANGELOG.md
@@ -1,3 +1,34 @@
+## 2.3.0 (27.06.2022)
+
+### Fixes and improvements
+
+- [Sidenav](https://mdbootstrap.com/docs/b5/angular/navigation/sidenav/)
+ - Resolved problems with arrow position updates in slim mode and accordion mode
+ - Resolved problem with initialization of component with `[right]="true"` and `[hidden]="false"` options
+ - Fixed problem with long content display in component with `[right]="true"` option
+- Fixed problems with long label positioning in [checkbox](https://mdbootstrap.com/docs/b5/angular/forms/checkbox/), [switch](https://mdbootstrap.com/docs/b5/angular/forms/switch/) and [radio](https://mdbootstrap.com/docs/b5/angular/forms/radio/)
+- Resolved problem with multiple `paginationChange` events emitted on [datatable](https://mdbootstrap.com/docs/b5/angular/data/datatables/) initialization
+- Resolved problems with [pagination](https://mdbootstrap.com/docs/b5/angular/navigation/pagination/) and [accordion](https://mdbootstrap.com/docs/b5/angular/components/accordion/) styles when using [theme](https://mdbootstrap.com/docs/b5/angular/content-styles/theme/)
+- Fixed problem with max file quantity in [file upload](https://mdbootstrap.com/docs/b5/angular/plugins/file-upload/) plugin with `multiple` mode
+- Resolved problem with first option highlight in [select](https://mdbootstrap.com/docs/b5/angular/forms/select/) with a `[highlightFirst]="false"` option
+- Added `type="button"` to the 'insert horizontal line' button in [WYSIWYG](https://mdbootstrap.com/docs/b5/angular/plugins/wysiwyg-editor/) to resolve problem with form submit
+- Zero-length [tooltip](https://mdbootstrap.com/docs/b5/angular/components/tooltips/) and [popover](https://mdbootstrap.com/docs/b5/angular/components/popovers/) will no longer be displayed
+- Fixed problem with multiple `(selected)` events emitted after click on [autocomplete](https://mdbootstrap.com/docs/b5/angular/forms/autocomplete/) option
+
+### New
+
+- Addew new [onboarding plugin](https://mdbootstrap.com/docs/b5/angular/plugins/onboarding/)
+- [Stepper](https://mdbootstrap.com/docs/b5/angular/components/stepper/)
+ - Added possibility to block step navigation on step header click
+ - Added possibility to edit buttons and header text in mobile mode
+- Added new `--mdb-bg-opacity` CSS variable
+- Added optional auto select on tab-out in [select](https://mdbootstrap.com/docs/b5/angular/forms/select/) and [autocomplete](https://mdbootstrap.com/docs/b5/angular/forms/autocomplete/)
+- Added list group new variant with `.list-group-light` class
+- Added `.table-group-divider` and `.table-divider-color` classes to emphasize the separation of thead from tbody
+- Added new `.divider-horizontal`, `.divider-vertical`, `.divider-horizontal-blurry` and `.divider-vertical-blurry` classes
+
+---
+
## 2.2.0 (16.05.2022)
### Fixes and improvements:
diff --git a/projects/mdb-angular-ui-kit/assets/scss/free/_list-group.scss b/projects/mdb-angular-ui-kit/assets/scss/free/_list-group.scss
index 10625b9a..a1e9eeb2 100644
--- a/projects/mdb-angular-ui-kit/assets/scss/free/_list-group.scss
+++ b/projects/mdb-angular-ui-kit/assets/scss/free/_list-group.scss
@@ -8,3 +8,36 @@
transition: 0.5s;
}
}
+
+.list-group-light {
+ .list-group-item {
+ padding: 1rem 0;
+ border: 2px solid hsl(0, 0%, 96%);
+ }
+ > .list-group-item {
+ border-width: 0 0 2px;
+ &:last-of-type {
+ border: none;
+ }
+ }
+ .active {
+ border: none;
+ border-radius: 0.5rem;
+ background-color: hsl(217, 88.2%, 90%);
+ color: hsl(217, 88.8%, 35.1%);
+ }
+ .list-group-item-action {
+ &:hover {
+ border-radius: 0.5rem;
+ }
+ &:focus {
+ border-radius: 0.5rem;
+ }
+ }
+}
+
+.list-group-small {
+ .list-group-item {
+ padding: 0.5rem 0;
+ }
+}
diff --git a/projects/mdb-angular-ui-kit/assets/scss/free/_root.scss b/projects/mdb-angular-ui-kit/assets/scss/free/_root.scss
index 92ea4a83..19c4abe5 100644
--- a/projects/mdb-angular-ui-kit/assets/scss/free/_root.scss
+++ b/projects/mdb-angular-ui-kit/assets/scss/free/_root.scss
@@ -1,3 +1,4 @@
:root {
--mdb-font-roboto: #{inspect($font-family-roboto)};
+ --mdb-bg-opacity: 1;
}
diff --git a/projects/mdb-angular-ui-kit/assets/scss/free/_tables.scss b/projects/mdb-angular-ui-kit/assets/scss/free/_tables.scss
index 7eb10c95..3eec4297 100644
--- a/projects/mdb-angular-ui-kit/assets/scss/free/_tables.scss
+++ b/projects/mdb-angular-ui-kit/assets/scss/free/_tables.scss
@@ -42,3 +42,12 @@
background-color: var(--#{$variable-prefix}table-hover-bg);
}
}
+
+.table-group-divider {
+ border-top: (2 * $table-border-width) solid;
+ border-top-color: inherit;
+}
+
+.table-divider-color {
+ border-top-color: rgba(0, 0, 0, 0.1);
+}
diff --git a/projects/mdb-angular-ui-kit/assets/scss/free/_utilities.scss b/projects/mdb-angular-ui-kit/assets/scss/free/_utilities.scss
index fa9a3997..016d00ab 100644
--- a/projects/mdb-angular-ui-kit/assets/scss/free/_utilities.scss
+++ b/projects/mdb-angular-ui-kit/assets/scss/free/_utilities.scss
@@ -174,3 +174,34 @@ $utilities: map-merge(
),
)
);
+
+hr.divider-horizontal:not([size]) {
+ height: 2px;
+}
+
+.divider-horizontal {
+ opacity: 1;
+ background-color: #f5f5f5;
+ height: 2px;
+}
+
+.divider-vertical {
+ opacity: 1;
+ background-color: #f5f5f5;
+ display: inline-block;
+ width: 2px;
+ margin: 0 1rem;
+}
+
+hr.divider-horizontal-blurry {
+ background-image: linear-gradient(90deg, transparent, hsl(0, 0%, 40%), transparent);
+ background-color: transparent;
+}
+
+hr.divider-vertical-blurry {
+ background-image: linear-gradient(180deg, transparent, hsl(0, 0%, 40%), transparent);
+ background-color: transparent;
+ width: 1px;
+ top: 0;
+ right: 0;
+}
diff --git a/projects/mdb-angular-ui-kit/assets/scss/free/forms/_form-check.scss b/projects/mdb-angular-ui-kit/assets/scss/free/forms/_form-check.scss
index 8bebc699..8b9a93f2 100644
--- a/projects/mdb-angular-ui-kit/assets/scss/free/forms/_form-check.scss
+++ b/projects/mdb-angular-ui-kit/assets/scss/free/forms/_form-check.scss
@@ -83,7 +83,7 @@
&[type='checkbox'] {
border-radius: $form-check-input-checkbox-border-radius;
margin-top: 0.19em;
- margin-right: 8px;
+ margin-right: 4px;
&:focus {
&:after {
@@ -153,7 +153,7 @@
width: $form-check-input-radio-width;
height: $form-check-input-radio-height;
margin-top: 0.125em;
- margin-right: 6px;
+ margin-right: 4px;
&:before {
width: $form-check-input-radio-before-width;
@@ -214,7 +214,7 @@
height: $form-switch-form-check-input-height;
background-color: $form-switch-form-check-input-background-color;
margin-top: 0.3em;
- margin-right: 8px;
+ margin-right: 4px;
&:after {
content: '';
diff --git a/projects/mdb-angular-ui-kit/collapse/collapse.directive.spec.ts b/projects/mdb-angular-ui-kit/collapse/collapse.directive.spec.ts
index 803ab4e8..d44a8168 100644
--- a/projects/mdb-angular-ui-kit/collapse/collapse.directive.spec.ts
+++ b/projects/mdb-angular-ui-kit/collapse/collapse.directive.spec.ts
@@ -1,10 +1,11 @@
-import { Component } from '@angular/core';
-import { ComponentFixture, TestBed } from '@angular/core/testing';
+import { Component, ViewChild } from '@angular/core';
+import { ComponentFixture, fakeAsync, flush, TestBed, tick } from '@angular/core/testing';
+import { MdbCollapseDirective } from '.';
import { MdbCollapseModule } from './collapse.module';
const template = `
-
+
Collapse directive content
`;
@@ -14,12 +15,13 @@ const template = `
template,
})
class TestCollapseComponent {
+ @ViewChild('collapse') collapse: MdbCollapseDirective;
+
collapsed = true;
- onShown = () => {};
- onHidden = () => {};
}
describe('MDB Collapse', () => {
+ const ANIMATION_TIME = 355;
let fixture: ComponentFixture
;
let element: any;
let component: any;
@@ -42,28 +44,68 @@ describe('MDB Collapse', () => {
expect(collapse.classList.contains('show')).toBe(false);
});
- it('should have content expanded if collapsed input is set to false', () => {
- // const onShownSpy = jest.spyOn(component, 'onShown');
- // component.collapsed = false;
- // fixture.detectChanges();
- // onShownSpy.and.callFake(() => {
- // expect(collapse.classList.contains('show')).toBe(true);
- // });
- });
+ it('should be expanded if collapsed input is set to false', fakeAsync(() => {
+ component.collapsed = false;
+ fixture.detectChanges();
- it('should allow toggling component by clicking on another element', () => {
- // const onShownSpy = jest.spyOn(component, 'onShown');
- // const onHiddenSpy = jest.spyOn(component, 'onHidden');
- // const buttonEl = fixture.nativeElement.querySelector('#button');
- // buttonEl.click();
- // fixture.detectChanges();
- // onShownSpy.and.callFake(() => {
- // expect(collapse.classList.contains('show')).toBe(true);
- // });
- // buttonEl.click();
- // fixture.detectChanges();
- // onHiddenSpy.and.callFake(() => {
- // expect(collapse.classList.contains('show')).toBe(false);
- // });
- });
+ tick(ANIMATION_TIME);
+ flush();
+ fixture.detectChanges();
+
+ expect(collapse.classList).toContain('show');
+ }));
+
+ it('should allow toggling component by clicking on another element', fakeAsync(() => {
+ const button = fixture.nativeElement.querySelector('button');
+
+ expect(collapse.classList).not.toContain('show');
+
+ button.click();
+ fixture.detectChanges();
+
+ tick(ANIMATION_TIME);
+ flush();
+ fixture.detectChanges();
+
+ expect(collapse.classList).toContain('show');
+
+ button.click();
+ fixture.detectChanges();
+
+ tick(ANIMATION_TIME);
+ flush();
+ fixture.detectChanges();
+
+ expect(collapse.classList).not.toContain('show');
+ }));
+
+ it('should emit events on collapse and expand', fakeAsync(() => {
+ const button = fixture.nativeElement.querySelector('button');
+ const showSpy = jest.spyOn(component.collapse.collapseShow, 'emit');
+ const shownSpy = jest.spyOn(component.collapse.collapseShown, 'emit');
+ const hideSpy = jest.spyOn(component.collapse.collapseHide, 'emit');
+ const hiddenSpy = jest.spyOn(component.collapse.collapseHidden, 'emit');
+
+ button.click();
+ fixture.detectChanges();
+
+ expect(showSpy).toHaveBeenCalled();
+
+ tick(ANIMATION_TIME);
+ flush();
+ fixture.detectChanges();
+
+ expect(shownSpy).toHaveBeenCalled();
+
+ button.click();
+ fixture.detectChanges();
+
+ expect(hideSpy).toHaveBeenCalled();
+
+ tick(ANIMATION_TIME);
+ flush();
+ fixture.detectChanges();
+
+ expect(hiddenSpy).toHaveBeenCalled();
+ }));
});
diff --git a/projects/mdb-angular-ui-kit/dropdown/dropdown.directive.spec.ts b/projects/mdb-angular-ui-kit/dropdown/dropdown.directive.spec.ts
index 067c2de8..de5f362b 100644
--- a/projects/mdb-angular-ui-kit/dropdown/dropdown.directive.spec.ts
+++ b/projects/mdb-angular-ui-kit/dropdown/dropdown.directive.spec.ts
@@ -1,5 +1,5 @@
import { ComponentFixture, fakeAsync, flush, inject, TestBed } from '@angular/core/testing';
-import { Component, DebugElement, Directive } from '@angular/core';
+import { Component, DebugElement } from '@angular/core';
import { MdbDropdownModule } from './index';
import { MdbDropdownDirective } from './index';
import { By } from '@angular/platform-browser';
@@ -10,13 +10,12 @@ describe('MDB Dropdown', () => {
let fixture: ComponentFixture;
let element: any;
let component: TestDropdownComponent;
- let directive: any;
- let debugElement: DebugElement;
+ let directive: MdbDropdownDirective;
let overlayContainer: OverlayContainer;
let overlayContainerElement: HTMLElement;
- beforeEach(async () => {
- await TestBed.configureTestingModule({
+ beforeEach(() => {
+ TestBed.configureTestingModule({
imports: [MdbDropdownModule, NoopAnimationsModule],
declarations: [TestDropdownComponent],
teardown: { destroyAfterEach: false },
@@ -30,7 +29,9 @@ describe('MDB Dropdown', () => {
fixture = TestBed.createComponent(TestDropdownComponent);
component = fixture.componentInstance;
element = fixture.nativeElement;
- debugElement = fixture.debugElement;
+ directive = fixture.debugElement
+ .query(By.directive(MdbDropdownDirective))
+ .injector.get(MdbDropdownDirective);
fixture.detectChanges();
});
@@ -40,127 +41,92 @@ describe('MDB Dropdown', () => {
overlayContainer.ngOnDestroy();
}));
- describe('after init', () => {
- it('should create the component', () => {
- expect(component).toBeTruthy();
- });
-
+ describe('Opening and closing', () => {
it('should open and close dropdown on click', fakeAsync(() => {
- directive = fixture.debugElement
- .query(By.directive(MdbDropdownDirective))
- .injector.get(MdbDropdownDirective) as MdbDropdownDirective;
-
- const onOpen = jest.spyOn(directive, 'show');
- const onClose = jest.spyOn(directive, 'hide');
+ jest.spyOn(directive, 'show');
+ jest.spyOn(directive, 'hide');
- const buttonEl = debugElement.query(By.css('.dropdown-toggle')).nativeElement;
+ const buttonEl: HTMLButtonElement = element.querySelector('.dropdown-toggle');
- buttonEl.dispatchEvent(new Event('click'));
+ buttonEl.click();
fixture.detectChanges();
- flush();
expect(directive.show).toHaveBeenCalled();
expect(overlayContainerElement.textContent).toContain('Action');
- buttonEl.dispatchEvent(new Event('click'));
+ buttonEl.click();
fixture.detectChanges();
+
flush();
+ fixture.detectChanges();
expect(directive.hide).toHaveBeenCalled();
- expect(overlayContainerElement.textContent).toContain('');
+ expect(overlayContainerElement.textContent).toEqual('');
}));
- it('should don`t modify dropdown position', () => {
- directive = fixture.debugElement
- .query(By.directive(MdbDropdownDirective))
- .injector.get(MdbDropdownDirective) as MdbDropdownDirective;
-
- const buttonEl = debugElement.query(By.css('.dropdown-toggle')).nativeElement;
-
- buttonEl.dispatchEvent(new Event('click'));
-
- expect(directive._isDropUp).toBe(false);
- expect(directive._isDropStart).toBe(false);
- expect(directive._isDropEnd).toBe(false);
- expect(directive._isDropdownMenuEnd).toBe(false);
- expect(directive._xPosition).toBe('start');
- });
-
- it('should set dropup', () => {
- component.positionClass = 'dropup';
-
+ it('should close dropdown on outside click', fakeAsync(() => {
+ directive.show();
fixture.detectChanges();
- directive = fixture.debugElement
- .query(By.directive(MdbDropdownDirective))
- .injector.get(MdbDropdownDirective) as MdbDropdownDirective;
-
- const buttonEl = debugElement.query(By.css('.dropdown-toggle')).nativeElement;
-
- buttonEl.dispatchEvent(new Event('click'));
-
- expect(directive._isDropUp).toBe(true);
- });
-
- it('should set dropstart', () => {
- component.positionClass = 'dropstart';
+ document.body.click();
+ fixture.detectChanges();
+ flush();
fixture.detectChanges();
- directive = fixture.debugElement
- .query(By.directive(MdbDropdownDirective))
- .injector.get(MdbDropdownDirective) as MdbDropdownDirective;
+ expect(overlayContainerElement.textContent).toEqual('');
+ }));
- const buttonEl = debugElement.query(By.css('.dropdown-toggle')).nativeElement;
+ it('should not close dropdown on outside click if closeOnOutsideClick is set to false', fakeAsync(() => {
+ component.closeOnOutsideClick = false;
+ directive.show();
+ fixture.detectChanges();
- buttonEl.dispatchEvent(new Event('click'));
+ document.body.click();
+ fixture.detectChanges();
- expect(directive._isDropStart).toBe(true);
- });
+ flush();
+ fixture.detectChanges();
- it('should set dropend', () => {
- component.positionClass = 'dropend';
+ expect(overlayContainerElement.textContent).toContain('Action');
+ }));
+ it('should close dropdown on dropdown item click', fakeAsync(() => {
+ directive.show();
fixture.detectChanges();
- directive = fixture.debugElement
- .query(By.directive(MdbDropdownDirective))
- .injector.get(MdbDropdownDirective) as MdbDropdownDirective;
-
- const buttonEl = debugElement.query(By.css('.dropdown-toggle')).nativeElement;
+ const item: HTMLElement = document.querySelector('.dropdown-item');
- buttonEl.dispatchEvent(new Event('click'));
+ item.click();
+ fixture.detectChanges();
- expect(directive._isDropEnd).toBe(true);
- });
+ flush();
+ fixture.detectChanges();
- it('should set dropdownMenuEnd', () => {
- component.menuEndClass = 'dropdown-menu-end';
+ expect(overlayContainerElement.textContent).toEqual('');
+ }));
+ it('should not close dropdown on dropdown item click if closeOnItemClick is set to false', fakeAsync(() => {
+ component.closeOnItemClick = false;
+ directive.show();
fixture.detectChanges();
- directive = fixture.debugElement
- .query(By.directive(MdbDropdownDirective))
- .injector.get(MdbDropdownDirective) as MdbDropdownDirective;
+ const item: HTMLElement = document.querySelector('.dropdown-item');
- const buttonEl = debugElement.query(By.css('.dropdown-toggle')).nativeElement;
+ item.click();
+ fixture.detectChanges();
- buttonEl.dispatchEvent(new Event('click'));
+ flush();
+ fixture.detectChanges();
- expect(directive._isDropdownMenuEnd).toBe(true);
- expect(directive._xPosition).toBe('end');
- });
+ expect(overlayContainerElement.textContent).toContain('Action');
+ }));
});
describe('Keyboard navigation', () => {
- it('should correctly focus dropdown items when ArrowUp or ArrowDown key is used', fakeAsync(() => {
- directive = fixture.debugElement
- .query(By.directive(MdbDropdownDirective))
- .injector.get(MdbDropdownDirective) as MdbDropdownDirective;
-
+ it('should correctly focus dropdown items when ArrowUp or ArrowDown key is used', () => {
directive.show();
fixture.detectChanges();
- flush();
const menu = document.querySelector('.dropdown-menu');
const items = menu.querySelectorAll('.dropdown-item');
@@ -179,16 +145,11 @@ describe('MDB Dropdown', () => {
fixture.detectChanges();
expect(document.activeElement).toBe(items[0]);
- }));
-
- it('should focus last option if ArrowUp is used and no item is selected', fakeAsync(() => {
- directive = fixture.debugElement
- .query(By.directive(MdbDropdownDirective))
- .injector.get(MdbDropdownDirective) as MdbDropdownDirective;
+ });
+ it('should focus last option if ArrowUp is used and no item is selected', () => {
directive.show();
fixture.detectChanges();
- flush();
const menu = document.querySelector('.dropdown-menu');
const items = menu.querySelectorAll('.dropdown-item');
@@ -197,6 +158,33 @@ describe('MDB Dropdown', () => {
fixture.detectChanges();
expect(document.activeElement).toBe(items[items.length - 1]);
+ });
+
+ it('should close dropdown on ESC keyup', fakeAsync(() => {
+ directive.show();
+ fixture.detectChanges();
+
+ document.dispatchEvent(new KeyboardEvent('keyup', { key: 'Escape' }));
+ fixture.detectChanges();
+
+ flush();
+ fixture.detectChanges();
+
+ expect(overlayContainerElement.textContent).toEqual('');
+ }));
+
+ it('should not close dropdown on ESC keyup if closeOnEsc is set to false', fakeAsync(() => {
+ component.closeOnEsc = false;
+ directive.show();
+ fixture.detectChanges();
+
+ document.dispatchEvent(new KeyboardEvent('keyup', { key: 'Escape' }));
+ fixture.detectChanges();
+
+ flush();
+ fixture.detectChanges();
+
+ expect(overlayContainerElement.textContent).toContain('Action');
}));
});
});
@@ -204,14 +192,15 @@ describe('MDB Dropdown', () => {
@Component({
selector: 'mdb-dropdown-test',
template: `
-