(el: HTMLElement)
| 230 | }; |
| 231 | |
| 232 | export 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 |
no test coverage detected