Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

compose: Show tooltip instantly for a `.disabled-on-hover` button.

N-Shar-ma15b3ad746632
diff --git a/web/src/compose_tooltips.js b/web/src/compose_tooltips.js
index 67697e5bde6..800c9058e6e 100644
--- a/web/src/compose_tooltips.js
+++ b/web/src/compose_tooltips.js
@@ -10,7 +10,7 @@ import * as compose_validate from "./compose_validate";
import {$t} from "./i18n";
import * as narrow_state from "./narrow_state";
import * as popover_menus from "./popover_menus";
-import {EXTRA_LONG_HOVER_DELAY, LONG_HOVER_DELAY} from "./tippyjs";
+import {EXTRA_LONG_HOVER_DELAY, INSTANT_HOVER_DELAY, LONG_HOVER_DELAY} from "./tippyjs";
import {parse_html} from "./ui_util";
import {user_settings} from "./user_settings";
@@ -56,6 +56,16 @@ export function initialize() {
// This ensures that the upload files tooltip
// doesn't hide behind the left sidebar.
appendTo: () => document.body,
+ // If the button is `.disabled-on-hover`, then we want to show the
+ // tooltip instantly, to make it clear to the user that the button
+ // is disabled, and why.
+ onTrigger(instance, event) {
+ if (event.currentTarget.classList.contains("disabled-on-hover")) {
+ instance.setProps({delay: INSTANT_HOVER_DELAY});
+ } else {
+ instance.setProps({delay: LONG_HOVER_DELAY});
+ }
+ },
});
delegate("body", {
diff --git a/web/src/tippyjs.ts b/web/src/tippyjs.ts
index 955e95cb8e1..f9d114b0faf 100644
--- a/web/src/tippyjs.ts
+++ b/web/src/tippyjs.ts
@@ -28,7 +28,7 @@ function get_tooltip_content(reference: Element): string | Element | DocumentFra
// transition, while the "long" version is intended for elements where
// we want to avoid distracting the user with the tooltip
// unnecessarily.
-const INSTANT_HOVER_DELAY: [number, number] = [100, 20];
+export const INSTANT_HOVER_DELAY: [number, number] = [100, 20];
// INTERACTIVE_HOVER_DELAY is for elements like the emoji reactions, where
// the tooltip includes useful information (who reacted?), but that
// needs a short delay for users who are just tapping a reaction