globocom / megadraft

Megadraft is a Rich Text editor built on top of Facebook's Draft.JS featuring a nice default base of components and extensibility

Home Page:http://megadraft.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Can't edit after removing container

ri8ika opened this issue · comments

I am not using CommonBlock as per plugin example. I have a button which calls the following function to remove the container. But after this the content is not editable. It only becomes accessible after window is reloaded.

this.props.container.remove()

I think I need to update the editorState. But not sure how to update it?

@ri8ika this problem occurs if you use a focusable element to invoke container methods

@ri8ika you can add stopPropagation on root element block

import React, { PureComponent } from 'react';
class Block extends PureComponent {
   render() {
     return (
        <div
             className="root-ement-block"
              onFocus={(e) => e.stopPropagation()}
              onBlur={(e) => e.stopPropagation()}
        >
            <button onClick={() => this.props.container.remove()}>remove</botton>
            ....
        </div>
     )
  }
}
commented

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.