Autofocus search and fix bugs

Signed-off-by: Tulir Asokan <tulir@maunium.net>
pull/21833/head
Tulir Asokan 2019-10-15 18:22:18 +03:00
parent 824685ae64
commit 7acae6dc32
3 changed files with 16 additions and 5 deletions

View File

@ -142,8 +142,6 @@ class EmojiPicker extends React.Component {
this.onClickEmoji = this.onClickEmoji.bind(this); this.onClickEmoji = this.onClickEmoji.bind(this);
this.scrollToCategory = this.scrollToCategory.bind(this); this.scrollToCategory = this.scrollToCategory.bind(this);
this.updateVisibility = this.updateVisibility.bind(this); this.updateVisibility = this.updateVisibility.bind(this);
window.bodyRef = this.bodyRef;
} }
updateVisibility() { updateVisibility() {

View File

@ -25,11 +25,21 @@ class Search extends React.PureComponent {
onChange: PropTypes.func.isRequired, onChange: PropTypes.func.isRequired,
}; };
constructor(props) {
super(props);
this.inputRef = React.createRef();
}
componentDidMount() {
// For some reason, neither the autoFocus nor just calling focus() here worked, so here's a setTimeout
setTimeout(() => this.inputRef.current.focus(), 0);
}
render() { render() {
return ( return (
<div className="mx_EmojiPicker_search"> <div className="mx_EmojiPicker_search">
<input type="text" placeholder="Search" value={this.props.query} <input autoFocus type="text" placeholder="Search" value={this.props.query}
onChange={ev => this.props.onChange(ev.target.value)}/> onChange={ev => this.props.onChange(ev.target.value)} ref={this.inputRef}/>
<button onClick={() => this.props.onChange("")} <button onClick={() => this.props.onChange("")}
className={this.props.query ? "mx_EmojiPicker_search_clear" : ""}> className={this.props.query ? "mx_EmojiPicker_search_clear" : ""}>
{this.props.query ? icons.search.delete() : icons.search.search()} {this.props.query ? icons.search.delete() : icons.search.search()}

View File

@ -90,11 +90,14 @@ export default class MessageActionBar extends React.PureComponent {
const buttonRect = ev.target.getBoundingClientRect(); const buttonRect = ev.target.getBoundingClientRect();
const getReactions = () => { const getReactions = () => {
if (!this.props.reactions) {
return [];
}
const userId = MatrixClientPeg.get().getUserId(); const userId = MatrixClientPeg.get().getUserId();
const myAnnotations = this.props.reactions.getAnnotationsBySender()[userId]; const myAnnotations = this.props.reactions.getAnnotationsBySender()[userId];
return Object.fromEntries([...myAnnotations] return Object.fromEntries([...myAnnotations]
.filter(event => !event.isRedacted()) .filter(event => !event.isRedacted())
.map(event => [event.getRelation().key, event.getId()])) .map(event => [event.getRelation().key, event.getId()]));
}; };
const menuOptions = { const menuOptions = {