Skip to content

The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:

Fix flakes because we used JS instead of CSS (#70718)

Mahatthana (Kelvin) Nomsawadi04b141b9754b
diff --git a/frontend/src/metabase/notifications/modals/QuestionAlertListModal/AlertListItem.module.css b/frontend/src/metabase/notifications/modals/QuestionAlertListModal/AlertListItem.module.css
index 1cbbe6b1a84..500afced009 100644
--- a/frontend/src/metabase/notifications/modals/QuestionAlertListModal/AlertListItem.module.css
+++ b/frontend/src/metabase/notifications/modals/QuestionAlertListModal/AlertListItem.module.css
@@ -29,7 +29,12 @@
color: var(--mb-color-text-secondary);
}
+.notificationListItem:hover .actionButtonContainer {
+ display: block;
+}
+
.actionButtonContainer {
+ display: none;
position: absolute;
/* 1rem - 0.6875rem (small icon button paddings) */
diff --git a/frontend/src/metabase/notifications/modals/QuestionAlertListModal/AlertListItem.tsx b/frontend/src/metabase/notifications/modals/QuestionAlertListModal/AlertListItem.tsx
index 85725c100ed..0e019d13a70 100644
--- a/frontend/src/metabase/notifications/modals/QuestionAlertListModal/AlertListItem.tsx
+++ b/frontend/src/metabase/notifications/modals/QuestionAlertListModal/AlertListItem.tsx
@@ -1,5 +1,5 @@
import cx from "classnames";
-import { type MouseEvent, useState } from "react";
+import type { MouseEvent } from "react";
import { msgid, ngettext, t } from "ttag";
import _ from "underscore";
@@ -46,8 +46,6 @@ export const AlertListItem = ({
}: AlertListItemProps) => {
const user = useSelector(getUser);
- const [showHoverActions, setShowHoverActions] = useState(false);
-
const { emailHandler, slackHandler, hookHandlers } =
getNotificationHandlersGroupedByTypes(alert.handlers);
const subscription = alert.subscriptions[0];
@@ -70,14 +68,6 @@ export const AlertListItem = ({
onDelete(alert);
};
- const handleMouseEnter = () => {
- setShowHoverActions(true);
- };
-
- const handleMouseLeave = () => {
- setShowHoverActions(false);
- };
-
return (
<Box
className={cx(
@@ -86,8 +76,6 @@ export const AlertListItem = ({
)}
p="1rem"
onClick={handleEdit}
- onMouseEnter={handleMouseEnter}
- onMouseLeave={handleMouseLeave}
>
<Text className={S.itemTitle} size="md" lineClamp={1} fw="bold">
{formatTitle(alert.payload.send_condition)}
@@ -136,23 +124,21 @@ export const AlertListItem = ({
</Group>
)}
</Stack>
- {showHoverActions && (
- <div className={S.actionButtonContainer}>
- {canEdit ? (
- <AlertListItemActionButton
- label={t`Delete this alert`}
- iconName="trash"
- onClick={handleDelete}
- />
- ) : (
- <AlertListItemActionButton
- label={t`Unsubscribe from this`}
- iconName="unsubscribe"
- onClick={handleUnsubscribe}
- />
- )}
- </div>
- )}
+ <div className={S.actionButtonContainer}>
+ {canEdit ? (
+ <AlertListItemActionButton
+ label={t`Delete this alert`}
+ iconName="trash"
+ onClick={handleDelete}
+ />
+ ) : (
+ <AlertListItemActionButton
+ label={t`Unsubscribe from this`}
+ iconName="unsubscribe"
+ onClick={handleUnsubscribe}
+ />
+ )}
+ </div>
</Box>
);
};