Dropdown option box stick issue
I have many dropdown in one form but what happened in page, when i click on dropdown then option box appear but when i page scroll option box stay at same location its doesnt scroll with page scroll
Please see below example https://stackblitz.com/angular/klqkgppymlk
replace `dropdown-sample-1.component.html' file with below code
<div class="sample-wrapper" style="overflow: auto;">
<button class="button" igxButton="raised" (click)="toggleDropDown($event)" [igxDropDownItemNavigation]="dropdown1" >Options</button>
<igx-drop-down #dropdown1 [width]="'100px'">
<igx-drop-down-item *ngFor="let item of items">
{{ item.field }}
</igx-drop-down-item>
</igx-drop-down>
<br/><br/>
<button class="button" igxButton="raised" (click)="toggleDropDown($event)" [igxDropDownItemNavigation]="dropdown1" >Options</button>
<igx-drop-down #dropdown1 [width]="'100px'">
<igx-drop-down-item *ngFor="let item of items">
{{ item.field }}
</igx-drop-down-item>
</igx-drop-down>
<br/><br/>
<button class="button" igxButton="raised" (click)="toggleDropDown($event)" [igxDropDownItemNavigation]="dropdown1" >Options</button>
<igx-drop-down #dropdown1 [width]="'100px'">
<igx-drop-down-item *ngFor="let item of items">
{{ item.field }}
</igx-drop-down-item>
</igx-drop-down>
<br/><br/>
<button class="button" igxButton="raised" (click)="toggleDropDown($event)" [igxDropDownItemNavigation]="dropdown1" >Options</button>
<igx-drop-down #dropdown1 [width]="'100px'">
<igx-drop-down-item *ngFor="let item of items">
{{ item.field }}
</igx-drop-down-item>
</igx-drop-down>
<br/><br/>
<button class="button" igxButton="raised" (click)="toggleDropDown($event)" [igxDropDownItemNavigation]="dropdown1" >Options</button>
<igx-drop-down #dropdown1 [width]="'100px'">
<igx-drop-down-item *ngFor="let item of items">
{{ item.field }}
</igx-drop-down-item>
</igx-drop-down>
<br/><br/>
<button class="button" igxButton="raised" (click)="toggleDropDown($event)" [igxDropDownItemNavigation]="dropdown1" >Options</button>
<igx-drop-down #dropdown1 [width]="'100px'">
<igx-drop-down-item *ngFor="let item of items">
{{ item.field }}
</igx-drop-down-item>
</igx-drop-down>
<br/><br/>
<button class="button" igxButton="raised" (click)="toggleDropDown($event)" [igxDropDownItemNavigation]="dropdown1" >Options</button>
<igx-drop-down #dropdown1 [width]="'100px'">
<igx-drop-down-item *ngFor="let item of items">
{{ item.field }}
</igx-drop-down-item>
</igx-drop-down>
<br/><br/>
<button class="button" igxButton="raised" (click)="toggleDropDown($event)" [igxDropDownItemNavigation]="dropdown1" >Options</button>
<igx-drop-down #dropdown1 [width]="'100px'">
<igx-drop-down-item *ngFor="let item of items">
{{ item.field }}
</igx-drop-down-item>
</igx-drop-down>
<br/><br/>
<button class="button" igxButton="raised" (click)="toggleDropDown($event)" [igxDropDownItemNavigation]="dropdown1" >Options</button>
<igx-drop-down #dropdown1 [width]="'100px'">
<igx-drop-down-item *ngFor="let item of items">
{{ item.field }}
</igx-drop-down-item>
</igx-drop-down>
<br/><br/>
<button class="button" igxButton="raised" (click)="toggleDropDown($event)" [igxDropDownItemNavigation]="dropdown1" >Options</button>
<igx-drop-down #dropdown1 [width]="'100px'">
<igx-drop-down-item *ngFor="let item of items">
{{ item.field }}
</igx-drop-down-item>
</igx-drop-down>
<br/><br/>
<button class="button" igxButton="raised" (click)="toggleDropDown($event)" [igxDropDownItemNavigation]="dropdown1" >Options</button>
<igx-drop-down #dropdown1 [width]="'100px'">
<igx-drop-down-item *ngFor="let item of items">
{{ item.field }}
</igx-drop-down-item>
</igx-drop-down>
<br/><br/>
<button class="button" igxButton="raised" (click)="toggleDropDown($event)" [igxDropDownItemNavigation]="dropdown1" >Options</button>
<igx-drop-down #dropdown1 [width]="'100px'">
<igx-drop-down-item *ngFor="let item of items">
{{ item.field }}
</igx-drop-down-item>
</igx-drop-down>
<br/><br/>
<button class="button" igxButton="raised" (click)="toggleDropDown($event)" [igxDropDownItemNavigation]="dropdown1" >Options</button>
<igx-drop-down #dropdown1 [width]="'100px'">
<igx-drop-down-item *ngFor="let item of items">
{{ item.field }}
</igx-drop-down-item>
</igx-drop-down>
</div>
Then select any button and option box appear and scroll page and see option box is still at same location and doesnt scroll with page scroll
I have same issue in my page but i am using this below code for dropdown
<div id="grp_wrapper">
<igx-input-group type="border" #grp style="width: 200px;" (click)="onClick()">
<input igxInput #txt id="txt" name="txt" type="text" [(ngModel)]="var.status" readonly />
<label igxLabel for="txt">Status</label>
<igx-suffix><igx-icon [name]="arrow"></igx-icon></igx-suffix>
</igx-input-group>
<igx-drop-down #dd igxDropDownItemNavigation width="200px" (onSelection)="onSelection($event)" (onClosed)="onClosed()">
<igx-drop-down-item *ngFor="let dataitem of items">
{{ dataitem.status }}
</igx-drop-down-item>
</igx-drop-down>
</div>
I dont know how to solve it, please let me know if anyone know solutions for this issue.
@nikunjgajera Hi we will check this after the holidays. Happy holidays ! :)
Hi, @nikunjgajera.
Here is a sample that is closing the drop down when you scroll. What I have added was the parameter to the CloseScrollStrategy constructor, which is the DIV container in your demo. This tells the overlay that it will listen to the scroll event of that container. Without the parameter the overlay will listen to the scroll event of the HTML body, but in your demo, the scrolled container is the DIV, not the body.
this._overlaySettings.scrollStrategy = new CloseScrollStrategy(this.mainContainer.nativeElement);
In addition I have commented the following code, which you can use if you want the drop down to move with the button, instead of closing it.
this._overlaySettings.scrollStrategy = new AbsoluteScrollStrategy();
Here is a sample with all available scroll strategies. I will wait for your feedback.
Thanks @Lipata Its working perfectly that i want