Skip to content

Commit 8d91cdb

Browse files
authored
Merge pull request #15287 from IgniteUI/mvenkov/pass-toggle-target-to-toggle-19.0
Use provided in open method partial overlay settings - 19.0
2 parents d4bf5f6 + 063924f commit 8d91cdb

File tree

3 files changed

+27
-3
lines changed

3 files changed

+27
-3
lines changed

projects/igniteui-angular/src/lib/dialog/dialog.component.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,7 @@ export class IgxDialogComponent implements IToggleView, OnInit, OnDestroy, After
478478
const eventArgs: IDialogCancellableEventArgs = { dialog: this, event: null, cancel: false };
479479
this.opening.emit(eventArgs);
480480
if (!eventArgs.cancel) {
481+
overlaySettings = { ...{}, ... this._overlayDefaultSettings, ...overlaySettings };
481482
this.toggleRef.open(overlaySettings);
482483
this.isOpenChange.emit(true);
483484
if (!this.leftButtonLabel && !this.rightButtonLabel) {

projects/igniteui-angular/src/lib/drop-down/drop-down.component.spec.ts

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,6 @@ describe('IgxDropDown ', () => {
256256
expect(positionStrategy.settings.horizontalDirection).toBe(HorizontalAlignment.Right);
257257
expect(positionStrategy.settings.verticalDirection).toBe(VerticalAlignment.Bottom);
258258
});
259-
260259
it('should apply custom overlay settings if provided', () => {
261260
const toggle: IgxToggleDirective = (dropdown as any).toggleDirective;
262261
const customOverlaySettings: OverlaySettings = {
@@ -1266,6 +1265,31 @@ describe('IgxDropDown ', () => {
12661265
expect(dropdown.closing.emit).toHaveBeenCalledTimes(3);
12671266
expect(dropdown.closed.emit).toHaveBeenCalledTimes(3);
12681267
}));
1268+
it('#15137 - should bind to custom target if provided', fakeAsync(() => {
1269+
const input = fixture.debugElement.query(By.css('input'));
1270+
dropdown.open({ target: input.nativeElement });
1271+
tick();
1272+
fixture.detectChanges();
1273+
1274+
const dropdownItems = fixture.debugElement.queryAll(By.css(`.${CSS_CLASS_ITEM}`));
1275+
expect(dropdownItems).not.toBeUndefined();
1276+
1277+
const inputRect = input.nativeElement.getBoundingClientRect();
1278+
let dropdownRect = dropdownItems[0].nativeElement.getBoundingClientRect();
1279+
expect(dropdownRect.left).toBe(inputRect.left);
1280+
expect(dropdownRect.top).toBe(inputRect.bottom);
1281+
1282+
dropdown.close();
1283+
tick();
1284+
fixture.detectChanges();
1285+
dropdown.open();
1286+
tick();
1287+
fixture.detectChanges();
1288+
1289+
dropdownRect = dropdownItems[0].nativeElement.getBoundingClientRect();
1290+
expect(dropdownRect.left).toBe(0);
1291+
expect(dropdownRect.top).toBe(0);
1292+
}));
12691293
});
12701294
});
12711295
});
@@ -1341,7 +1365,6 @@ class DoubleIgxDropDownComponent implements OnInit {
13411365
}
13421366
}
13431367
}
1344-
13451368
@Component({
13461369
template: `
13471370
<input (click)="toggleDropDown()">

projects/igniteui-angular/src/lib/drop-down/drop-down.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ export class IgxDropDownComponent extends IgxDropDownBaseDirective implements ID
243243
* ```
244244
*/
245245
public open(overlaySettings?: OverlaySettings) {
246-
const settings = overlaySettings || this.getDefaultOverlaySettings();
246+
const settings = { ... {}, ...this.getDefaultOverlaySettings(), ...overlaySettings };
247247
this.toggleDirective.open(settings);
248248
this.updateScrollPosition();
249249
}

0 commit comments

Comments
 (0)