From 043b4a418724ab701fd1a0dc133713417eef5b97 Mon Sep 17 00:00:00 2001 From: Joffrey JAFFEUX Date: Mon, 23 Oct 2023 21:09:02 +0200 Subject: [PATCH] FIX: replaces data-tooltip usage by (#24062) As much as possible I would like us to avoid having to go the with a global event listener on click/mouseover. For now I have removed all cases of `data-tooltip`, if we clearly identify a use case of a global event listener we might reconsider this. The following changes are also included: - by default tooltips won't attempt to focus first focusable element anymore - tooltip will now use `cursor: pointer` by default - a new service has been introduced: `InternalTooltip` which is responsible to track the current instance displayed by a ``. Portal elements when replaced are not properly cleaned and I couldn't figure out a way to have a proper hook to ensure the previous `DTooltipInstance` is properly set as not expanded; this problem was very visible when using a tooltip as interactive and hovering another tooltip, which would replace the interactive tooltip as not closed. --- .../admin/addon/components/admin-report.hbs | 37 ++++++++++--------- .../admin/addon/templates/api-keys-new.hbs | 11 +++--- .../admin/addon/templates/api-keys-show.hbs | 11 +++--- .../discourse/app/components/d-modal.hbs | 2 +- .../discourse/app/modifiers/trap-tab.js | 10 +++-- .../components/admin-report-test.js | 10 ++--- .../addon/components/d-float-body.gjs | 2 +- .../float-kit/addon/components/d-tooltip.gjs | 6 ++- .../addon/services/internal-tooltip.js | 12 ++++++ .../app/services/internal-tooltip.js | 1 + .../common/float-kit/d-tooltip.scss | 1 + 11 files changed, 62 insertions(+), 41 deletions(-) create mode 100644 app/assets/javascripts/float-kit/addon/services/internal-tooltip.js create mode 100644 app/assets/javascripts/float-kit/app/services/internal-tooltip.js diff --git a/app/assets/javascripts/admin/addon/components/admin-report.hbs b/app/assets/javascripts/admin/addon/components/admin-report.hbs index 0854431e1fa..7c0171dc81c 100644 --- a/app/assets/javascripts/admin/addon/components/admin-report.hbs +++ b/app/assets/javascripts/admin/addon/components/admin-report.hbs @@ -24,24 +24,27 @@ {{#if this.model.description}} - {{#if this.model.description_link}} - + + <:trigger> {{d-icon "question-circle"}} - - {{else}} - - {{d-icon "question-circle"}} - - {{/if}} + + <:content> + {{#if this.model.description_link}} + + {{this.model.description}} + + {{else}} + {{this.model.description}} + {{/if}} + + {{/if}} {{/unless}} diff --git a/app/assets/javascripts/admin/addon/templates/api-keys-new.hbs b/app/assets/javascripts/admin/addon/templates/api-keys-new.hbs index d616fd390b4..4e0fc952c6c 100644 --- a/app/assets/javascripts/admin/addon/templates/api-keys-new.hbs +++ b/app/assets/javascripts/admin/addon/templates/api-keys-new.hbs @@ -88,16 +88,15 @@
{{act.name}}
- - {{d-icon "question-circle"}} - + /> {{scope.resource}} {{scope.action}} - - {{d-icon "question-circle"}} - + class="scope-tooltip" + />