show shorter placeholder for filter feed when not focused

This commit is contained in:
Bruno Windels 2019-09-10 10:58:11 +02:00
parent da98080859
commit 15d3774665
3 changed files with 15 additions and 3 deletions

View file

@ -263,7 +263,8 @@ const LeftPanel = createReactClass({
const searchBox = (<SearchBox const searchBox = (<SearchBox
enableRoomSearchFocus={true} enableRoomSearchFocus={true}
placeholder={ _t('Filter room names') } blurredPlaceholder={ _t('Filter') }
placeholder={ _t('Filter rooms…') }
onSearch={ this.onSearch } onSearch={ this.onSearch }
onCleared={ this.onSearchCleared } onCleared={ this.onSearchCleared }
onFocus={this._onSearchFocus} onFocus={this._onSearchFocus}

View file

@ -22,6 +22,7 @@ import { KeyCode } from '../../Keyboard';
import dis from '../../dispatcher'; import dis from '../../dispatcher';
import { throttle } from 'lodash'; import { throttle } from 'lodash';
import AccessibleButton from '../../components/views/elements/AccessibleButton'; import AccessibleButton from '../../components/views/elements/AccessibleButton';
import classNames from 'classnames';
module.exports = createReactClass({ module.exports = createReactClass({
displayName: 'SearchBox', displayName: 'SearchBox',
@ -47,6 +48,7 @@ module.exports = createReactClass({
getInitialState: function() { getInitialState: function() {
return { return {
searchTerm: "", searchTerm: "",
blurred: true,
}; };
}, },
@ -94,6 +96,7 @@ module.exports = createReactClass({
}, },
_onFocus: function(ev) { _onFocus: function(ev) {
this.setState({blurred: false});
ev.target.select(); ev.target.select();
if (this.props.onFocus) { if (this.props.onFocus) {
this.props.onFocus(ev); this.props.onFocus(ev);
@ -101,6 +104,7 @@ module.exports = createReactClass({
}, },
_onBlur: function(ev) { _onBlur: function(ev) {
this.setState({blurred: true});
if (this.props.onBlur) { if (this.props.onBlur) {
this.props.onBlur(ev); this.props.onBlur(ev);
} }
@ -128,6 +132,12 @@ module.exports = createReactClass({
onClick={ () => {this._clearSearch("button"); } }> onClick={ () => {this._clearSearch("button"); } }>
</AccessibleButton>) : undefined; </AccessibleButton>) : undefined;
// show a shorter placeholder when blurred, if requested
// this is used for the room filter field that has
// the explore button next to it when blurred
const placeholder = this.state.blurred ?
(this.props.blurredPlaceholder || this.props.placeholder) :
this.props.placeholder;
const className = this.props.className || ""; const className = this.props.className || "";
return ( return (
<div className="mx_SearchBox mx_textinput"> <div className="mx_SearchBox mx_textinput">
@ -140,8 +150,8 @@ module.exports = createReactClass({
onFocus={ this._onFocus } onFocus={ this._onFocus }
onChange={ this.onChange } onChange={ this.onChange }
onKeyDown={ this._onKeyDown } onKeyDown={ this._onKeyDown }
placeholder={ this.props.placeholder }
onBlur={this._onBlur} onBlur={this._onBlur}
placeholder={ placeholder }
/> />
{ clearButton } { clearButton }
</div> </div>

View file

@ -1549,8 +1549,9 @@
"Community %(groupId)s not found": "Community %(groupId)s not found", "Community %(groupId)s not found": "Community %(groupId)s not found",
"This homeserver does not support communities": "This homeserver does not support communities", "This homeserver does not support communities": "This homeserver does not support communities",
"Failed to load %(groupId)s": "Failed to load %(groupId)s", "Failed to load %(groupId)s": "Failed to load %(groupId)s",
"Filter room names": "Filter room names",
"Explore": "Explore", "Explore": "Explore",
"Filter": "Filter",
"Filter rooms…": "Filter rooms…",
"Failed to reject invitation": "Failed to reject invitation", "Failed to reject invitation": "Failed to reject invitation",
"This room is not public. You will not be able to rejoin without an invite.": "This room is not public. You will not be able to rejoin without an invite.", "This room is not public. You will not be able to rejoin without an invite.": "This room is not public. You will not be able to rejoin without an invite.",
"Are you sure you want to leave the room '%(roomName)s'?": "Are you sure you want to leave the room '%(roomName)s'?", "Are you sure you want to leave the room '%(roomName)s'?": "Are you sure you want to leave the room '%(roomName)s'?",