MCPcopy Index your code
hub / github.com/angular/components / open

Method open

src/material/timepicker/timepicker.ts:245–284  ·  view source on GitHub ↗

Opens the timepicker.

()

Source from the content-addressed store, hash-verified

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 {

Callers

nothing calls this directly

Calls 11

_generateOptionsMethod · 0.95
_getOverlayRefMethod · 0.95
_syncSelectedStateMethod · 0.95
setMethod · 0.80
focusMethod · 0.65
getOverlayOriginMethod · 0.65
hasAttachedMethod · 0.65
attachMethod · 0.65
destroyMethod · 0.65
updateSizeMethod · 0.45
valueMethod · 0.45

Tested by

no test coverage detected