Skip to content

Commit

Permalink
fix(select): error when opening a ly-select has no ly-option
Browse files Browse the repository at this point in the history
  • Loading branch information
Enlcxx committed Jul 15, 2020
1 parent 2dc19b3 commit 83995cd
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/lib/select/select.ts
Original file line number Diff line number Diff line change
Expand Up @@ -660,9 +660,14 @@ export class LySelect
this._renderer.setStyle(container, 'width', `${panelWidth}px`);


const selectedElement: HTMLElement = this._selectionModel.isEmpty()
? el.querySelector('ly-option')!
: this._selectionModel.selected[0]._getHostElement();
let selectedElement: HTMLElement | null = this._selectionModel.isEmpty()
? el.querySelector('ly-option')
: this._selectionModel.selected[0]._getHostElement() as HTMLElement;

if (!selectedElement) {
selectedElement = (el.firstElementChild!.firstElementChild! || el.firstElementChild!) as HTMLElement;
}


const offset = {
y: -(nativeElement.offsetHeight / 2 + selectedElement.offsetTop + selectedElement.offsetHeight / 2),
Expand Down

0 comments on commit 83995cd

Please sign in to comment.