handlechangeMessage(event){
this.setState({
Message:event
})
}
onselect(event){
this.handlechangeMessage(event)
this.setState({ showData: false
})
}
onKeyPress(event){
if(this.state.Message.charAt(this.state.Message.length-1) === "@"){
if(event.key == '{'){
this.setState({
showData:true,
})}
}}
<div >
<label htmlFor="edit-keyword-title" style={{ width: "100%" }}>
Message</label> {/* Needs to get from Admin Configuration */}
<div style={{ display:"flex", flexDirection:"row"}}>
<input type="text" className="Description-message-container" maxLength="100"
value={this.state.Message}onKeyPress={this.onKeyPress} onChange={(event) => this.handlechangeMessage(event.target.value)}/>
</div>
</div>
{this.state.showData &&
<div className="keywords-list" >
{filteredData.map((row) => (
<div onClick={()=>this.onselect(this.state.Message.slice(0,this.state.Message.lastIndexOf("{")+1) + row.name)}>
<div className="inner-keywords"> {row.name}</div>
</div>
))}
</div>
}
当前输出:
预期输出: