Opens the timepicker.
()
| 243 | |
| 244 | /** Opens the timepicker. */ |
| 245 | open(): void { |
| 246 | const input = this._input(); |
| 247 | |
| 248 | if (!input) { |
| 249 | return; |
| 250 | } |
| 251 | |
| 252 | // Focus should already be on the input, but this call is in case the timepicker is opened |
| 253 | // programmatically. We need to call this even if the timepicker is already open, because |
| 254 | // the user might be clicking the toggle. |
| 255 | input.focus(); |
| 256 | |
| 257 | if (this._isOpen()) { |
| 258 | return; |
| 259 | } |
| 260 | |
| 261 | this._isOpen.set(true); |
| 262 | this._generateOptions(); |
| 263 | const overlayRef = this._getOverlayRef(); |
| 264 | overlayRef.updateSize({width: input.getOverlayOrigin().nativeElement.offsetWidth}); |
| 265 | this._portal ??= new TemplatePortal(this._panelTemplate(), this._viewContainerRef); |
| 266 | |
| 267 | // We need to check this in case `isOpen` was flipped, but change detection hasn't |
| 268 | // had a chance to run yet. See https://github.com/angular/components/issues/30637 |
| 269 | if (!overlayRef.hasAttached()) { |
| 270 | overlayRef.attach(this._portal); |
| 271 | } |
| 272 | |
| 273 | this._onOpenRender?.destroy(); |
| 274 | this._onOpenRender = afterNextRender( |
| 275 | () => { |
| 276 | const options = this._options(); |
| 277 | this._syncSelectedState(input.value(), options, options[0]); |
| 278 | this._onOpenRender = null; |
| 279 | }, |
| 280 | {injector: this._injector}, |
| 281 | ); |
| 282 | |
| 283 | this.opened.emit(); |
| 284 | } |
| 285 | |
| 286 | /** Closes the timepicker. */ |
| 287 | close(): void { |
nothing calls this directly
no test coverage detected