ianstormtaylor / slate

A completely customizable framework for building rich text editors. (Currently in beta.)
http://slatejs.org
MIT License
29.83k stars 3.24k forks source link

Mentions functionality errors. #3071

Closed blindibrasil closed 4 years ago

blindibrasil commented 5 years ago

Do you want to request a feature or report a bug?

error

Text editor code: https://gist.github.com/blindibrasil/0823834ba65b87d89239ab2497592355

What is the current behavior?

I am trying to implement the mentions option in my editor, but I am experiencing some issues with this functionality.

Problems:

1 - When using the code that is in the documentation, I come across the following problem;

Unhandled Rejection (TypeError): Cannot read property 'getBoundingClientRect' of null;

Captura de tela de 2019-10-16 15-56-50

2 - Trying to get around the problem I commented the line in question that was giving error, leaving as follows:

// const anchorRect = anchorSelector.getBoundingClientRect ();

      setPosition ({
        top: window.pageYOffset,
        left: window.pageXOffset,
      });

That way I was able to access my editor correctly, but other problems arose. When you type @ and type another letter to appear the mentions suggestions, these two errors happen:

Captura de tela de 2019-10-16 16-01-14

2.1 - The suggestions screen is in the corner of the screen. 2.2 - And the second mistake is this: I have tried to correct in several ways but I still can not.  Warning: State updates from useState () and useReducer () Hooks don't support the second callback argument. To perform a side effect after rendering, declare it in the body component with useEffect (). I believe it may be coming from the onChange function;

3 - Once in the suggestion popup nothing happens, if I double click it mentions the text correctly, but gives another error in the console identical to the one mentioned in point 2.2, and does not close the suggestion popup. Captura de tela de 2019-10-16 16-07-30

And if you click on the popup again a new error appears.

TypeError: Cannot read property 'length' of null

Captura de tela de 2019-10-16 16-09-25

What is the expected behavior?

The expected behavior is when typing @ and writing, pop up the suggestions popup to be inserted into the text and after clicking once the popup disappears.

Thank you very much to everyone on the Slate team.

ianstormtaylor commented 4 years ago

I believe that this may be fixed by https://github.com/ianstormtaylor/slate/pull/3093, which has changed a lot of the logic in Slate and slate-react especially. I'm going to close this out, but as always, feel free to open a new issue if it persists for you. Thanks for understanding.