Undo the last action when clicking on the text field

オープン
#445 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
45/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
停滞
技術スタック
html, react, typescript
領域
frontend

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

説明

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

主要言語
TypeScript
スター
428
フォーク
48
平均マージ
5日 15時間
マージ済み PR(30日)
47

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

gravity-ui/markdown-editor のほかの issue

gravity-ui/markdown-editor の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。