Skip to content

Commit 483b0e6

Browse files
committed
chore(select): Use base-fit positioning #5911
Update Dev sample. Comment overflow-y.
1 parent f3c29ba commit 483b0e6

File tree

7 files changed

+190
-81
lines changed

7 files changed

+190
-81
lines changed

projects/igniteui-angular/src/lib/core/styles/components/drop-down/_drop-down-theme.scss

+1-1
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@
211211
}
212212

213213
%igx-drop-down__list {
214-
overflow-y: auto;
214+
// overflow-y: auto;
215215
z-index: 1;
216216
box-shadow: --var($theme, 'shadow');
217217
background: --var($theme, 'background-color');

projects/igniteui-angular/src/lib/select/select-positioning-strategy.ts

+124-72
Large diffs are not rendered by default.

projects/igniteui-angular/src/lib/select/select.common.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@ export interface IgxSelectBase extends IgxDropDownBase {
1717
getFooterContainer(): HTMLElement;
1818
getHeaderTemplate(): TemplateRef<any> ;
1919
getFooterTemplate(): TemplateRef<any> ;
20-
getEditElement(): HTMLElement;
20+
getEditElement(): HTMLElement; // returns input HTMLElement
2121
}

projects/igniteui-angular/src/lib/services/overlay/position/base-fit-position-strategy.ts

+13-6
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ export abstract class BaseFitPositionStrategy extends ConnectedPositioningStrate
3434
connectedFit.targetRect,
3535
connectedFit.contentElementRect,
3636
this.settings.horizontalStartPoint,
37-
this.settings.horizontalDirection);
37+
this.settings.horizontalDirection,
38+
connectedFit.xOffset);
3839
connectedFit.right = connectedFit.left + connectedFit.contentElementRect.width;
3940
connectedFit.fitHorizontal =
4041
connectedFit.viewPortRect.left < connectedFit.left && connectedFit.right < connectedFit.viewPortRect.right;
@@ -43,7 +44,8 @@ export abstract class BaseFitPositionStrategy extends ConnectedPositioningStrate
4344
connectedFit.targetRect,
4445
connectedFit.contentElementRect,
4546
this.settings.verticalStartPoint,
46-
this.settings.verticalDirection);
47+
this.settings.verticalDirection,
48+
connectedFit.yOffset);
4749
connectedFit.bottom = connectedFit.top + connectedFit.contentElementRect.height;
4850
connectedFit.fitVertical =
4951
connectedFit.viewPortRect.top < connectedFit.top && connectedFit.bottom < connectedFit.viewPortRect.bottom;
@@ -58,8 +60,9 @@ export abstract class BaseFitPositionStrategy extends ConnectedPositioningStrate
5860
* @param direction Direction in which to show the element
5961
*/
6062
protected calculateLeft(
61-
targetRect: ClientRect, elementRect: ClientRect, startPoint: HorizontalAlignment, direction: HorizontalAlignment): number {
62-
return targetRect.right + targetRect.width * startPoint + elementRect.width * direction;
63+
targetRect: ClientRect, elementRect: ClientRect, startPoint: HorizontalAlignment, direction: HorizontalAlignment, offset?: number):
64+
number {
65+
return targetRect.right + targetRect.width * startPoint + elementRect.width * direction + offset;
6366
}
6467

6568
/**
@@ -71,8 +74,9 @@ export abstract class BaseFitPositionStrategy extends ConnectedPositioningStrate
7174
* @param direction Direction in which to show the element
7275
*/
7376
protected calculateTop(
74-
targetRect: ClientRect, elementRect: ClientRect, startPoint: VerticalAlignment, direction: VerticalAlignment): number {
75-
return targetRect.bottom + targetRect.height * startPoint + elementRect.height * direction;
77+
targetRect: ClientRect, elementRect: ClientRect, startPoint: VerticalAlignment, direction: VerticalAlignment, offset?: number):
78+
number {
79+
return targetRect.bottom + targetRect.height * startPoint + elementRect.height * direction + offset;
7680
}
7781

7882
/**
@@ -95,4 +99,7 @@ export interface ConnectedFit {
9599
right?: number;
96100
top?: number;
97101
bottom?: number;
102+
xOffset?: number;
103+
yOffset?: number;
98104
}
105+

src/app/select/select.sample.html

+38
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,33 @@
22
Several select components with a variety of setups and API interaction.
33
</app-page-header>
44

5+
<br/>
6+
<br/>
7+
<br/>
8+
<br/>
9+
<br/>
10+
<br/>
11+
<br/>
12+
<br/>
13+
<br/>
14+
<br/>
15+
<br/>
16+
<br/>
17+
<br/>
18+
<br/>
19+
<br/>
20+
<br/>
21+
<br/>
22+
<br/>
23+
<br/>
24+
<br/>
25+
<br/>
26+
<br/>
27+
<br/>
28+
<br/>
29+
<br/>
30+
<br/>
31+
532
<div class="sampleWrapper">
633
<h4 class="sample-title">Select with ngModel, set items OnInit</h4>
734
<igx-select #displayDensitySelect
@@ -23,6 +50,17 @@ <h4 class="sample-title">Select with ngModel, set items OnInit</h4>
2350
<igx-select-item *ngFor="let item of items; let inx=index" [value]="item.field">
2451
{{ item.field }}
2552
</igx-select-item>
53+
<ng-template igxSelectHeader>
54+
<div class="custom-select-header">
55+
I AM a HEADER
56+
</div>
57+
</ng-template>
58+
<ng-template igxSelectFooter>
59+
<div class="custom-select-footer">
60+
<igx-icon fontSet="material">add</igx-icon>
61+
<button igxButton="raised" (click)="addItem()">addItem</button>
62+
</div>
63+
</ng-template>
2664
</igx-select>
2765

2866
<div>

src/app/select/select.sample.scss

+8
Original file line numberDiff line numberDiff line change
@@ -97,3 +97,11 @@
9797
.warn {
9898
color: darkorange;
9999
}
100+
101+
.custom-select-header,
102+
.custom-select-footer {
103+
padding: 4px 8px;
104+
background: #777;
105+
text-align: center;
106+
box-shadow: 0 2px 4px rgba(0, 0, 0, .08);
107+
}

src/app/select/select.sample.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export class SelectSampleComponent implements OnInit {
3636
public items: any[] = [];
3737
public value: 'opt1';
3838
public disabledItemValue: 'InsideGroup1';
39-
public fruits: string[] = ['Orange', 'Apple', 'Banana', 'Mango'];
39+
public fruits: string[] = ['Orange', 'Apple', 'Banana', 'Mango', 'Pear', 'Lemon', 'Peach', 'Apricot', 'Grapes', 'Cactus'];
4040
public selected: string;
4141
public selectRequired = true;
4242

@@ -147,4 +147,8 @@ export class SelectSampleComponent implements OnInit {
147147
setDensity(density: DisplayDensity) {
148148
this.selectDisplayDensity.displayDensity = density;
149149
}
150+
151+
addItem() {
152+
// TODO
153+
}
150154
}

0 commit comments

Comments
 (0)