From 41d4813439e28d84610f8764df20a117db654c9d Mon Sep 17 00:00:00 2001 From: Michaela Robosova Date: Sun, 11 Aug 2024 10:43:14 +0200 Subject: [PATCH 01/28] Remove unnecessary live region mount from the documentation page. Mounting as part of the KThemePlugin execution seems to work well after all. --- docs/pages/usekliveregion.vue | 6 +----- lib/KThemePlugin.js | 4 ---- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/docs/pages/usekliveregion.vue b/docs/pages/usekliveregion.vue index be46710a3..a2729a510 100644 --- a/docs/pages/usekliveregion.vue +++ b/docs/pages/usekliveregion.vue @@ -93,7 +93,7 @@ export default { setup() { - const { _mountLiveRegion, sendPoliteMessage, sendAssertiveMessage } = useKLiveRegion(); + const { sendPoliteMessage, sendAssertiveMessage } = useKLiveRegion(); const politeMessageInput = ref('Polite hello'); const updatePoliteMessage = message => { @@ -106,7 +106,6 @@ }; return { - _mountLiveRegion, updatePoliteMessage, politeMessageInput, updateAssertiveMessage, @@ -115,9 +114,6 @@ sendAssertiveMessage, }; }, - mounted() { - this._mountLiveRegion(this.$root.$el); - }, }; diff --git a/lib/KThemePlugin.js b/lib/KThemePlugin.js index 8f7e377a4..3e41df74a 100644 --- a/lib/KThemePlugin.js +++ b/lib/KThemePlugin.js @@ -51,10 +51,6 @@ require('./grids/globalStyles.js'); // global grid styles * Also, set up global state, listeners, and styles. */ export default function KThemePlugin(Vue) { - // Note that if DOM live regions need to be demostrated - // on the KDS website, and therefore attached to the DOM, - // just call _mountLiveRegion() in the relevant documentation - // page's 'mounted' (see 'docs/pages/usekliveregio.vue' for an example) if (!isNuxtServerSideRendering()) { const onDomReady = () => { _mountLiveRegion(); From 52656ca3eaa7ce2148c826716872f5f6d8bc44c2 Mon Sep 17 00:00:00 2001 From: Michaela Robosova Date: Sun, 11 Aug 2024 10:03:32 +0200 Subject: [PATCH 02/28] Add support for teleporting that is performant and simple to use. - The teleport root element is inserted to an application's document body during KDS initialization - Removes the need for manual insert - Ensures we never attach teleported elements, such as tooltips, to document.body itself, which is said to cause severe performance problems (https://css-tricks.com/dont-attach-tooltips-to-document-body/) - Adds new `KTeleport` component - Wrapper around vue2-teleport with restricted API that only allows teleporting to the KDS teleport root element. - Removes Teleport in favour of KTeleport in KModal - Adds appendToRoot prop to KTooltip - In support of Studio migration to KDS where in a few instances, teleport is needed for tooltips to display correctly - Contains smaller refactor of Popper.vue to allow the tooltip be attached to an element different from document.body --- docs/pages/installation.vue | 3 +- docs/pages/kteleport.vue | 29 +++++++++ docs/pages/usekliveregion.vue | 2 +- docs/tableOfContents.js | 5 ++ lib/KModal.vue | 11 +--- lib/KTeleport/index.vue | 34 +++++++++++ lib/KThemePlugin.js | 5 ++ lib/KTooltip/Popper.vue | 26 ++++---- lib/KTooltip/index.vue | 16 +++++ .../__tests__/index.spec.js | 10 ++++ lib/composables/_useTeleportRootEl/index.js | 59 +++++++++++++++++++ .../useKLiveRegion/__tests__/index.spec.js | 2 +- 12 files changed, 180 insertions(+), 22 deletions(-) create mode 100644 docs/pages/kteleport.vue create mode 100644 lib/KTeleport/index.vue create mode 100644 lib/composables/_useTeleportRootEl/__tests__/index.spec.js create mode 100644 lib/composables/_useTeleportRootEl/index.js diff --git a/docs/pages/installation.vue b/docs/pages/installation.vue index 2dea90431..d1dad171b 100644 --- a/docs/pages/installation.vue +++ b/docs/pages/installation.vue @@ -24,7 +24,8 @@
  • Installs $themeBrand, $themeTokens $themePalette, and $computedClass helpers on all Vue instances (see ).
  • Provides $coreOutline, $inputModality, $mediaType, and $isPrint computed properties as well as $print method to all Vue instances.
  • Globally registers all KDS Vue components.
  • -
  • Inserts assertive and polite ARIA live regions to your application's document body (see ).
  • +
  • Inserts assertive and polite ARIA live regions #k-live-region to your application's document body (see ).
  • +
  • Inserts the teleport root element #k-teleport to your application's document body (see or search for appendToRoot prop on components).
  • diff --git a/docs/pages/kteleport.vue b/docs/pages/kteleport.vue new file mode 100644 index 000000000..c6a31e58a --- /dev/null +++ b/docs/pages/kteleport.vue @@ -0,0 +1,29 @@ + diff --git a/docs/pages/usekliveregion.vue b/docs/pages/usekliveregion.vue index a2729a510..88b273ae6 100644 --- a/docs/pages/usekliveregion.vue +++ b/docs/pages/usekliveregion.vue @@ -77,7 +77,7 @@
    • - that attaches live regions to an application's DOM + that attaches live regions to an application's document body
    diff --git a/docs/tableOfContents.js b/docs/tableOfContents.js index 3166c255b..01075c89e 100644 --- a/docs/tableOfContents.js +++ b/docs/tableOfContents.js @@ -399,6 +399,11 @@ export default [ isCode: true, keywords: tabsRelatedKeywords, }), + new Page({ + path: '/kteleport', + title: 'KTeleport', + isCode: true, + }), new Page({ path: '/ktransition', title: 'KTransition', diff --git a/lib/KModal.vue b/lib/KModal.vue index 1112d86e7..273345354 100644 --- a/lib/KModal.vue +++ b/lib/KModal.vue @@ -1,6 +1,6 @@