I'm trying to enter text via Rich Text by function. but cursor automatically getting outside the RichText. I already import essential component which need on it. I also tried it by onKeyUp instead on onChange but also not working.
It's working good when i'm trying it without the ArticleContent function, but not working when trying with this ArticleContent function.
Below is my codes (It's not working)
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>
)
},
});