Stay organized with collections
Save and categorize content based on your preferences.
blockly > FocusManager > takeEphemeralFocus
FocusManager.takeEphemeralFocus() method
Ephemerally captures focus for a specific element until the returned lambda is called. This is expected to be especially useful for ephemeral UI flows like dialogs.
IMPORTANT: the returned lambda *must* be called, otherwise automatic focus will no longer work anywhere on the page. It is highly recommended to tie the lambda call to the closure of the corresponding UI so that if input is manually changed to an element outside of the ephemeral UI, the UI should close and automatic input restored. Note that this lambda must be called exactly once and that subsequent calls will throw an error.
Note that the manager will continue to track DOM input signals even when ephemeral focus is active, but it won't actually change node state until the returned lambda is called. Additionally, only 1 ephemeral focus context can be active at any given time (attempting to activate more than one simultaneously will result in an error being thrown).
Signature:
takeEphemeralFocus(focusableElement: HTMLElement | SVGElement): ReturnEphemeralFocus;
Parameters
Parameter |
Type |
Description |
focusableElement |
HTMLElement | SVGElement |
|
Returns:
ReturnEphemeralFocus
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-05-16 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-05-16 UTC."],[],[],null,["[blockly](./blockly.md) \\\u003e [FocusManager](./blockly.focusmanager_class.md) \\\u003e [takeEphemeralFocus](./blockly.focusmanager_class.takeephemeralfocus_1_method.md)\n\nFocusManager.takeEphemeralFocus() method\n----------------------------------------\n\nEphemerally captures focus for a specific element until the returned lambda is called. This is expected to be especially useful for ephemeral UI flows like dialogs.\n\nIMPORTANT: the returned lambda \\*must\\* be called, otherwise automatic focus will no longer work anywhere on the page. It is highly recommended to tie the lambda call to the closure of the corresponding UI so that if input is manually changed to an element outside of the ephemeral UI, the UI should close and automatic input restored. Note that this lambda must be called exactly once and that subsequent calls will throw an error.\n\nNote that the manager will continue to track DOM input signals even when ephemeral focus is active, but it won't actually change node state until the returned lambda is called. Additionally, only 1 ephemeral focus context can be active at any given time (attempting to activate more than one simultaneously will result in an error being thrown).\n\n**Signature:** \n\n takeEphemeralFocus(focusableElement: HTMLElement | SVGElement): ReturnEphemeralFocus;\n\nParameters\n----------\n\n| Parameter | Type | Description |\n|------------------|---------------------------|-------------|\n| focusableElement | HTMLElement \\| SVGElement | |\n\n**Returns:**\n\n[ReturnEphemeralFocus](./blockly.returnephemeralfocus_typealias.md)"]]