MCPcopy Index your code
hub / github.com/ionic-team/ionic-framework / focusVisibleElement

Function focusVisibleElement

core/src/utils/helpers.ts:232–249  ·  view source on GitHub ↗
(el: HTMLElement)

Source from the content-addressed store, hash-verified

230};
231
232export const focusVisibleElement = (el: HTMLElement) => {
233 el.focus();
234
235 /**
236 * When programmatically focusing an element,
237 * the focus-visible utility will not run because
238 * it is expecting a keyboard event to have triggered this;
239 * however, there are times when we need to manually control
240 * this behavior so we call the `setFocus` method on ion-app
241 * which will let us explicitly set the elements to focus.
242 */
243 if (el.classList.contains('ion-focusable')) {
244 const app = el.closest('ion-app');
245 if (app) {
246 app.setFocus([el]);
247 }
248 }
249};
250
251/**
252 * This method is used to add a hidden input to a host element that contains

Callers 3

focusElementInContextFunction · 0.90
focusElementInOverlayFunction · 0.90

Calls 1

setFocusMethod · 0.45

Tested by

no test coverage detected