@ewc-lib/ewc-dialog
Advanced tools
Comparing version 2.0.6-alpha to 2.0.7-alpha
{ | ||
"name": "@ewc-lib/ewc-dialog", | ||
"version": "2.0.6-alpha", | ||
"version": "2.0.7-alpha", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "src/main.js", |
@@ -67,1 +67,15 @@ # Screenshot | ||
import "@ewc-lib/ewc-dialog" | ||
# Focus trap | ||
If bodyHtml contains elements which should be included in the focus trap - for example links - there's the possibility to set the focus trap's last element (to the last focusable element from the body html) - after which the first element (the close button) is focussed again, completing a cycle. | ||
Example: | ||
document.getElementById("infoModal").bodyHtml = `<a id="dialog_last_element" href="https://ec.europa.eu/eurostat" title="Link to Estat">Some Link Text</a>` | ||
document.getElementById("infoModal").visible = true | ||
document.getElementById("infoModal").focusTrap.setLastElement(document.getElementById("dialog_last_element") ) | ||
This way, the focus is still trapped within the dialog but also includes tab-focusable elements within the bodyHtml. | ||
Note that setLastElement() is called **after** the visible setter. |
70265
81