Курсор Gutenberg RichText автоматически фокусируется - PullRequest
0 голосов
/ 23 февраля 2020

Я пытаюсь ввести текст через Rich Text по функциям. но курсор автоматически выходит за пределы RichText. Я уже импортирую необходимый компонент, который нужен на нем. Я также попробовал это с помощью onKeyUp вместо этого на onChange, но также не работает.

Это работает хорошо, когда я пытаюсь это сделать без функции ArticleContent, но не работает при попытке с этой функцией ArticleContent.

See the photo, here i need to click every time on the rich text each for each character.

Ниже приведены мои коды (не работает)

registerBlockType('vixmi-support/test', {
    title: __('Test Block'),
    icon : {
        src       : 'media-spreadsheet'
    },
    category   : 'vixmi',
    description: 'Sample desc',
    keywords   : [
        __( 'Single Article' ),
        __( 'Article' ),
    ],

    supports:{
        align : true,
        anchor: true
    },

    // custom attributes
    attributes:{
        title: {
            type    : 'string',
            source  : 'html',
            selector: 'h4',
        },
        articleLayout: {
            type   : 'string',
            default: 'left',
        }
    },


    edit: ( {attributes, setAttributes} ) => {
        const{
            title, content, buttonTitle, buttonLink, linkTarget, articleLayout
        } = attributes;

        function UpdateArticleTitle(newTitle){
            setAttributes( { title:newTitle } )
        }
        function UpdateActionLayout(event){
            setAttributes( { articleLayout:event.target.value } )
        }

        function ArticleContent(props){
            const{
                title
            } = props.attributes;
            return(
                <RichText
                    key         = "editablec"
                    tagName     = "h4"
                    placeholder = "Article title"
                    value       = { title }
                    onChange    = { UpdateArticleTitle } />
            )
        }

        return([
            <div className="sample">
                <ArticleContent attributes={ attributes }/>
            </div>
        ])
    },
    save: ( {attributes} ) => {
        const{
            title
        } = attributes;

        return(
            <div className="sample">
                <h4>{title}</h4>
            </div>
        )
    },

});
...