Undo the last action when clicking on the text field

Abierto
#445 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
45/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Estancado
Stack tecnológico
html, react, typescript
Área
frontend

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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

Lenguaje dominante
TypeScript
Estrellas
428
Forks
48
Merge medio
5 d 15 h
PR fusionados (30 d)
47

Preparar el entorno

Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de gravity-ui/markdown-editor

Todos los issues de gravity-ui/markdown-editor

Issues similares

Más issues de TypeScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.