Undo the last action when clicking on the text field

Đang mở
#445 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
45/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
html, react, typescript
Lĩnh vực
frontend

Hướng nghiên cứu

Reproduce the issue by placing MarkdownEditorView inside a label and clicking the editor’s text field; the “Undo” toolbar action is incorrectly triggered. Start with the editor component and its click/event handling around the toolbar and text input. Done means clicking within the text field no longer activates “Undo,” while the toolbar action still works when clicked directly.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

enhancement

Отмена последнего действия при клике на текстовое поле

Description

Исходная компонента

import React from 'react';

import {
  MarkdownEditorView,
  useMarkdownEditor,
} from '@gravity-ui/markdown-editor';
import { toaster } from '@gravity-ui/uikit/toaster-singleton-react-18';

import { configure } from '@gravity-ui/markdown-editor';

configure({
  lang: 'ru',
});

type Props = {
  onChange: (value: string) => void;
};

export function Editor({ onChange }: Props) {
  const editor = useMarkdownEditor({
    initial: {
      toolbarVisible: true,
    },
  });

  React.useEffect(() => {
    function changeHandler() {
      const value = editor.getValue();
      onChange(value);
    }

    editor.on('change', changeHandler);
    return () => {
      editor.off('change', changeHandler);
    };
  }, [editor, onChange]);

  return (
    <MarkdownEditorView
      stickyToolbar
      toaster={toaster}
      editor={editor}
      settingsVisible={false}
      className="markdown-editor-wrapper"
    />
  );
}

Проблема - если наш эдитор поставить в тег тогда при клике будет срабатывать кнопка "Отменить"

<label>
   <Editor onChange={setDescription} />
</label>

https://github.com/user-attachments/assets/8b5f47bb-b158-4450-a78a-23a81534b5ee

Ngôn ngữ chính
TypeScript
Star
428
Fork
48
Merge trung bình
5 ngày 15 giờ
Pull request đã merge (30 ngày)
47

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của gravity-ui/markdown-editor

Tất cả issue của gravity-ui/markdown-editor

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.