fix(core): unexpected jump when clicking save tag (#8171)

close AF-1285

https://github.com/user-attachments/assets/1ec4adf5-4340-4e94-9e56-6a05e7a65f18
This commit is contained in:
JimmFly
2024-09-09 07:54:56 +00:00
parent 32f673fa3d
commit b48cc825e0
2 changed files with 8 additions and 0 deletions

View File

@@ -73,6 +73,7 @@ export const editTagWrapper = style({
width: '100%',
height: '60px',
display: 'none',
zIndex: 1,
selectors: {
'&[data-show=true]': {
background: cssVar('backgroundPrimaryColor'),

View File

@@ -3,6 +3,7 @@ import { TagService } from '@affine/core/modules/tag';
import { useI18n } from '@affine/i18n';
import { useLiveData, useService } from '@toeverything/infra';
import clsx from 'clsx';
import type { MouseEvent } from 'react';
import { useCallback, useEffect, useMemo, useState } from 'react';
import type { TagMeta } from '../types';
@@ -107,6 +108,11 @@ export const CreateOrEditTag = ({
return;
}, [onClose, t, tag, tagIcon, tagMeta, tagName, tagOptions, tagList]);
const handlePropagation = useCallback((event: MouseEvent) => {
event.preventDefault();
event.stopPropagation();
}, []);
useEffect(() => {
if (!open) return;
if (menuOpen) return;
@@ -138,6 +144,7 @@ export const CreateOrEditTag = ({
className={styles.createTagWrapper}
data-show={open}
data-testid="edit-tag-modal"
onClick={handlePropagation}
>
<Menu
rootOptions={{