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

Use provided in open method partial overlay settings #15286

Merged
merged 3 commits into from
Jan 22, 2025
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 @@ -478,6 +478,7 @@ export class IgxDialogComponent implements IToggleView, OnInit, OnDestroy, After
const eventArgs: IDialogCancellableEventArgs = { dialog: this, event: null, cancel: false };
this.opening.emit(eventArgs);
if (!eventArgs.cancel) {
overlaySettings = { ...{}, ... this._overlayDefaultSettings, ...overlaySettings };
this.toggleRef.open(overlaySettings);
this.isOpenChange.emit(true);
if (!this.leftButtonLabel && !this.rightButtonLabel) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,6 @@ describe('IgxDropDown ', () => {
expect(positionStrategy.settings.horizontalDirection).toBe(HorizontalAlignment.Right);
expect(positionStrategy.settings.verticalDirection).toBe(VerticalAlignment.Bottom);
});

it('should apply custom overlay settings if provided', () => {
const toggle: IgxToggleDirective = (dropdown as any).toggleDirective;
const customOverlaySettings: OverlaySettings = {
Expand Down Expand Up @@ -1266,6 +1265,31 @@ describe('IgxDropDown ', () => {
expect(dropdown.closing.emit).toHaveBeenCalledTimes(3);
expect(dropdown.closed.emit).toHaveBeenCalledTimes(3);
}));
it('#15137 - should bind to custom target if provided', fakeAsync(() => {
const input = fixture.debugElement.query(By.css('input'));
dropdown.open({ target: input.nativeElement });
tick();
fixture.detectChanges();

const dropdownItems = fixture.debugElement.queryAll(By.css(`.${CSS_CLASS_ITEM}`));
expect(dropdownItems).not.toBeUndefined();

const inputRect = input.nativeElement.getBoundingClientRect();
let dropdownRect = dropdownItems[0].nativeElement.getBoundingClientRect();
expect(dropdownRect.left).toBe(inputRect.left);
expect(dropdownRect.top).toBe(inputRect.bottom);

dropdown.close();
tick();
fixture.detectChanges();
dropdown.open();
tick();
fixture.detectChanges();

dropdownRect = dropdownItems[0].nativeElement.getBoundingClientRect();
expect(dropdownRect.left).toBe(0);
expect(dropdownRect.top).toBe(0);
}));
});
});
});
Expand Down Expand Up @@ -1341,7 +1365,6 @@ class DoubleIgxDropDownComponent implements OnInit {
}
}
}

@Component({
template: `
<input (click)="toggleDropDown()">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ export class IgxDropDownComponent extends IgxDropDownBaseDirective implements ID
* ```
*/
public open(overlaySettings?: OverlaySettings) {
const settings = overlaySettings || this.getDefaultOverlaySettings();
const settings = { ... {}, ...this.getDefaultOverlaySettings(), ...overlaySettings };
this.toggleDirective.open(settings);
this.updateScrollPosition();
}
Expand Down
Loading