Skip to content

Commit

Permalink
fix for vertical pickers
Browse files Browse the repository at this point in the history
  • Loading branch information
wouter-willems committed Jan 12, 2024
1 parent 8f25031 commit 2809329
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 8 deletions.
18 changes: 14 additions & 4 deletions projects/demo/src/app/demo/demo.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,20 @@
</ng-template>
</klp-form-select>

<div style="width: 300px; position: absolute">
<klp-form-select [options]="staticOptions" orientation="vertical"></klp-form-select>
</div>

<klp-form-button [clickCallback]="slowClick">
async button
</klp-form-button>

<div style="width: 300px; position: absolute">
<klp-form-select [options]="staticOptions" [truncateOptions]="true" orientation="vertical"></klp-form-select>
</div>

some cool stuff here <br />
some cool stuff here <br />
some cool stuff here <br />
some cool stuff here <br />
some cool stuff here <br />
some cool stuff here <br />
some cool stuff here <br />
some cool stuff here <br />
some cool stuff here <br />
2 changes: 1 addition & 1 deletion projects/klippa/ngx-enhancy-forms/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@klippa/ngx-enhancy-forms",
"version": "14.11.3",
"version": "14.11.4",
"publishConfig": {
"access": "public"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,10 @@ ng-select.showErrors {
::ng-deep .ng-dropdown-panel {
visibility: hidden;
}

&.verticalOrientation {
overflow: initial;
}
}
:host .ng-select.withSeparatingLine ::ng-deep .ng-dropdown-panel .ng-dropdown-panel-items .ng-option{
border-bottom: 1px solid #e3e3e3;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,12 +181,15 @@ export class SelectComponent extends ValueAccessorBase<string | string[]> implem
}

private setFixedDropdownPanelPosition = () => {
const dropdownPanel = this.elRef.nativeElement.querySelector('ng-dropdown-panel');
dropdownPanel.style.visibility = 'initial';
if (this.orientation === 'vertical') {
return;
}
const difference = this.anchorAbsolute.getBoundingClientRect().top - this.anchorFixed.getBoundingClientRect().top;
this.dropdownPanelOffsetY = difference;

const dropdownPanel = this.elRef.nativeElement.querySelector('ng-dropdown-panel');
dropdownPanel.style.position = 'fixed';
dropdownPanel.style.visibility = 'initial';
this.setPanelOffsets();
};

Expand Down Expand Up @@ -238,7 +241,12 @@ export class SelectComponent extends ValueAccessorBase<string | string[]> implem
const dropdownPanel = this.elRef.nativeElement.querySelector('ng-dropdown-panel');
const scrollPositionOffset = `translate(${this.dropdownPanelOffsetX}px, ${this.dropdownPanelOffsetY}px)`;
const dropdownPositionOffset = this.dropdownPositionToUse === 'top' ? `translateY(-100%) translateY(1px)` : '';
dropdownPanel.style.transform = [scrollPositionOffset, dropdownPositionOffset].join(' ');
if (this.orientation === 'vertical') {
dropdownPanel.style.transformOrigin = 'top left';
dropdownPanel.style.transform = `rotate(90deg) translateY(-${this.elRef.nativeElement.getBoundingClientRect().width}px)`;
} else {
dropdownPanel.style.transform = [scrollPositionOffset, dropdownPositionOffset].join(' ');
}
}

private determineDropdownPosition(): void {
Expand Down

0 comments on commit 2809329

Please sign in to comment.