Fixed mobile search focus - keyboard collapse/focus (#5766)

Этот коммит содержится в:
Saturnino Abril
2017-03-24 18:05:43 +09:00
коммит произвёл George Goldberg
родитель 98baf1536e
Коммит 1167b39185
5 изменённых файлов: 133 добавлений и 121 удалений

Просмотреть файл

@@ -1,12 +1,10 @@
// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved. // Copyright (c) 2015 Mattermost, Inc. All Rights Reserved.
// See License.txt for license information. // See License.txt for license information.
import SearchBox from './search_bar.jsx';
import CreateComment from './create_comment.jsx'; import CreateComment from './create_comment.jsx';
import RhsHeaderPost from './rhs_header_post.jsx'; import RhsHeaderPost from './rhs_header_post.jsx';
import RootPost from './rhs_root_post.jsx'; import RootPost from './rhs_root_post.jsx';
import Comment from './rhs_comment.jsx'; import Comment from './rhs_comment.jsx';
import FileUploadOverlay from './file_upload_overlay.jsx';
import FloatingTimestamp from './post_view/components/floating_timestamp.jsx'; import FloatingTimestamp from './post_view/components/floating_timestamp.jsx';
import DateSeparator from './post_view/components/date_separator.jsx'; import DateSeparator from './post_view/components/date_separator.jsx';
@@ -334,12 +332,6 @@ export default class RhsThread extends React.Component {
); );
} }
var currentId = UserStore.getCurrentId();
var searchForm;
if (currentId != null) {
searchForm = <SearchBox isCommentsPage={true}/>;
}
let profile; let profile;
if (UserStore.getCurrentId() === selected.user_id) { if (UserStore.getCurrentId() === selected.user_id) {
profile = this.props.currentUser; profile = this.props.currentUser;
@@ -407,66 +399,62 @@ export default class RhsThread extends React.Component {
} }
return ( return (
<div className='post-right__container'> <div className='sidebar-right__body'>
<FileUploadOverlay overlayType='right'/> <FloatingTimestamp
<div className='search-bar__container sidebar--right__search-header'>{searchForm}</div> isScrolling={this.state.isScrolling}
<div className='sidebar-right__body'> isMobile={Utils.isMobile()}
<FloatingTimestamp createAt={this.state.topRhsPostCreateAt}
isScrolling={this.state.isScrolling} isRhsPost={true}
isMobile={Utils.isMobile()} />
createAt={this.state.topRhsPostCreateAt} <RhsHeaderPost
isRhsPost={true} fromFlaggedPosts={this.props.fromFlaggedPosts}
/> fromSearch={this.props.fromSearch}
<RhsHeaderPost isWebrtc={this.props.isWebrtc}
fromFlaggedPosts={this.props.fromFlaggedPosts} isMentionSearch={this.props.isMentionSearch}
fromSearch={this.props.fromSearch} toggleSize={this.props.toggleSize}
isWebrtc={this.props.isWebrtc} shrink={this.props.shrink}
isMentionSearch={this.props.isMentionSearch} />
toggleSize={this.props.toggleSize} <Scrollbars
shrink={this.props.shrink} autoHide={true}
/> autoHideTimeout={500}
<Scrollbars autoHideDuration={500}
autoHide={true} renderThumbHorizontal={renderThumbHorizontal}
autoHideTimeout={500} renderThumbVertical={renderThumbVertical}
autoHideDuration={500} renderView={renderView}
renderThumbHorizontal={renderThumbHorizontal} onScroll={this.handleScroll}
renderThumbVertical={renderThumbVertical} >
renderView={renderView} <div className='post-right__scroll'>
onScroll={this.handleScroll} <DateSeparator
> date={previousPostDay}
<div className='post-right__scroll'> />
<DateSeparator <RootPost
date={previousPostDay} ref={selected.id}
/> post={selected}
<RootPost commentCount={postsArray.length}
ref={selected.id} user={profile}
post={selected} currentUser={this.props.currentUser}
commentCount={postsArray.length} compactDisplay={this.state.compactDisplay}
user={profile} useMilitaryTime={this.props.useMilitaryTime}
currentUser={this.props.currentUser} isFlagged={isRootFlagged}
compactDisplay={this.state.compactDisplay} status={rootStatus}
useMilitaryTime={this.props.useMilitaryTime} previewCollapsed={this.state.previewsCollapsed}
isFlagged={isRootFlagged} isBusy={this.state.isBusy}
status={rootStatus} />
previewCollapsed={this.state.previewsCollapsed} <div
isBusy={this.state.isBusy} ref='rhspostlist'
/> className='post-right-comments-container'
<div >
ref='rhspostlist' {commentsLists}
className='post-right-comments-container'
>
{commentsLists}
</div>
<div className='post-create__container'>
<CreateComment
channelId={selected.channel_id}
rootId={selected.id}
latestPostId={postsArray.length > 0 ? postsArray[postsArray.length - 1].id : selected.id}
/>
</div>
</div> </div>
</Scrollbars> <div className='post-create__container'>
</div> <CreateComment
channelId={selected.channel_id}
rootId={selected.id}
latestPostId={postsArray.length > 0 ? postsArray[postsArray.length - 1].id : selected.id}
/>
</div>
</div>
</Scrollbars>
</div> </div>
); );
} }

Просмотреть файл

@@ -1,7 +1,6 @@
// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved. // Copyright (c) 2015 Mattermost, Inc. All Rights Reserved.
// See License.txt for license information. // See License.txt for license information.
import $ from 'jquery';
import * as GlobalActions from 'actions/global_actions.jsx'; import * as GlobalActions from 'actions/global_actions.jsx';
import SearchStore from 'stores/search_store.jsx'; import SearchStore from 'stores/search_store.jsx';
import UserStore from 'stores/user_store.jsx'; import UserStore from 'stores/user_store.jsx';
@@ -31,7 +30,9 @@ export default class SearchBar extends React.Component {
this.handleUserFocus = this.handleUserFocus.bind(this); this.handleUserFocus = this.handleUserFocus.bind(this);
this.handleClear = this.handleClear.bind(this); this.handleClear = this.handleClear.bind(this);
this.handleUserBlur = this.handleUserBlur.bind(this); this.handleUserBlur = this.handleUserBlur.bind(this);
this.performSearch = this.performSearch.bind(this); this.handleSearch = this.handleSearch.bind(this);
this.handleSearchOnSuccess = this.handleSearchOnSuccess.bind(this);
this.handleSearchOnError = this.handleSearchOnError.bind(this);
this.handleSubmit = this.handleSubmit.bind(this); this.handleSubmit = this.handleSubmit.bind(this);
this.searchMentions = this.searchMentions.bind(this); this.searchMentions = this.searchMentions.bind(this);
this.getFlagged = this.getFlagged.bind(this); this.getFlagged = this.getFlagged.bind(this);
@@ -125,7 +126,7 @@ export default class SearchBar extends React.Component {
this.setState({focused: true}); this.setState({focused: true});
} }
performSearch(terms, isMentionSearch) { handleSearch(terms, isMentionSearch) {
if (terms.length) { if (terms.length) {
this.setState({ this.setState({
isSearching: true, isSearching: true,
@@ -136,23 +137,35 @@ export default class SearchBar extends React.Component {
terms, terms,
isMentionSearch, isMentionSearch,
() => { () => {
this.setState({isSearching: false}); this.handleSearchOnSuccess();
if (Utils.isMobile() && this.search) {
this.search.value = '';
}
}, },
() => { () => {
this.setState({isSearching: false}); this.handleSearchOnError();
} }
); );
} }
} }
handleSearchOnSuccess() {
if (this.mounted) {
this.setState({isSearching: false});
if (Utils.isMobile() && this.search) {
this.search.value = '';
}
}
}
handleSearchOnError() {
if (this.mounted) {
this.setState({isSearching: false});
}
}
handleSubmit(e) { handleSubmit(e) {
e.preventDefault(); e.preventDefault();
this.performSearch(this.state.searchTerm.trim()); this.handleSearch(this.state.searchTerm.trim());
$(this.search).find('input').blur(); this.search.blur();
} }
searchMentions(e) { searchMentions(e) {
@@ -310,7 +323,7 @@ export default class SearchBar extends React.Component {
listComponent={SearchSuggestionList} listComponent={SearchSuggestionList}
providers={this.suggestionProviders} providers={this.suggestionProviders}
type='search' type='search'
autoFocus={this.props.isFocus} autoFocus={this.props.isFocus && this.state.searchTerm === ''}
/> />
<div <div
className={clearClass} className={clearClass}

Просмотреть файл

@@ -3,7 +3,6 @@
import SearchResultsHeader from './search_results_header.jsx'; import SearchResultsHeader from './search_results_header.jsx';
import SearchResultsItem from './search_results_item.jsx'; import SearchResultsItem from './search_results_item.jsx';
import SearchBox from './search_bar.jsx';
import ChannelStore from 'stores/channel_store.jsx'; import ChannelStore from 'stores/channel_store.jsx';
import SearchStore from 'stores/search_store.jsx'; import SearchStore from 'stores/search_store.jsx';
@@ -168,11 +167,6 @@ export default class SearchResults extends React.Component {
render() { render() {
var results = this.state.results; var results = this.state.results;
var currentId = UserStore.getCurrentId();
var searchForm = null;
if (currentId) {
searchForm = <SearchBox isFocus={Utils.isMobile()}/>;
}
var noResults = (!results || !results.order || !results.order.length); var noResults = (!results || !results.order || !results.order.length);
const searchTerm = this.state.searchTerm; const searchTerm = this.state.searchTerm;
const profiles = this.state.profiles || {}; const profiles = this.state.profiles || {};
@@ -312,23 +306,20 @@ export default class SearchResults extends React.Component {
} }
return ( return (
<div className='sidebar--right__content'> <div className='sidebar-right__body'>
<div className='search-bar__container sidebar--right__search-header'>{searchForm}</div> <SearchResultsHeader
<div className='sidebar-right__body'> isMentionSearch={this.props.isMentionSearch}
<SearchResultsHeader toggleSize={this.props.toggleSize}
isMentionSearch={this.props.isMentionSearch} shrink={this.props.shrink}
toggleSize={this.props.toggleSize} isFlaggedPosts={this.props.isFlaggedPosts}
shrink={this.props.shrink} isPinnedPosts={this.props.isPinnedPosts}
isFlaggedPosts={this.props.isFlaggedPosts} channelDisplayName={this.props.channelDisplayName}
isPinnedPosts={this.props.isPinnedPosts} />
channelDisplayName={this.props.channelDisplayName} <div
/> id='search-items-container'
<div className='search-items-container'
id='search-items-container' >
className='search-items-container' {ctls}
>
{ctls}
</div>
</div> </div>
</div> </div>
); );

Просмотреть файл

@@ -5,6 +5,8 @@ import $ from 'jquery';
import SearchResults from './search_results.jsx'; import SearchResults from './search_results.jsx';
import RhsThread from './rhs_thread.jsx'; import RhsThread from './rhs_thread.jsx';
import SearchBox from './search_bar.jsx';
import FileUploadOverlay from './file_upload_overlay.jsx';
import SearchStore from 'stores/search_store.jsx'; import SearchStore from 'stores/search_store.jsx';
import PostStore from 'stores/post_store.jsx'; import PostStore from 'stores/post_store.jsx';
import UserStore from 'stores/user_store.jsx'; import UserStore from 'stores/user_store.jsx';
@@ -188,30 +190,43 @@ export default class SidebarRight extends React.Component {
expandedClass = 'sidebar--right--expanded'; expandedClass = 'sidebar--right--expanded';
} }
var currentId = UserStore.getCurrentId();
var searchForm = null;
if (currentId) {
searchForm = <SearchBox isFocus={this.state.searchVisible && Utils.isMobile()}/>;
}
if (this.state.searchVisible) { if (this.state.searchVisible) {
content = ( content = (
<SearchResults <div className='sidebar--right__content'>
isMentionSearch={this.state.isMentionSearch} <div className='search-bar__container sidebar--right__search-header'>{searchForm}</div>
isFlaggedPosts={this.state.isFlaggedPosts} <SearchResults
isPinnedPosts={this.state.isPinnedPosts} isMentionSearch={this.state.isMentionSearch}
useMilitaryTime={this.state.useMilitaryTime} isFlaggedPosts={this.state.isFlaggedPosts}
toggleSize={this.toggleSize} isPinnedPosts={this.state.isPinnedPosts}
shrink={this.onShrink} useMilitaryTime={this.state.useMilitaryTime}
channelDisplayName={this.props.channel ? this.props.channel.display_name : ''} toggleSize={this.toggleSize}
/> shrink={this.onShrink}
channelDisplayName={this.props.channel ? this.props.channel.display_name : ''}
/>
</div>
); );
} else if (this.state.postRightVisible) { } else if (this.state.postRightVisible) {
content = ( content = (
<RhsThread <div className='post-right__container'>
fromFlaggedPosts={this.state.fromFlaggedPosts} <FileUploadOverlay overlayType='right'/>
fromSearch={this.state.fromSearch} <div className='search-bar__container sidebar--right__search-header'>{searchForm}</div>
isWebrtc={WebrtcStore.isBusy()} <RhsThread
isMentionSearch={this.state.isMentionSearch} fromFlaggedPosts={this.state.fromFlaggedPosts}
currentUser={this.state.currentUser} fromSearch={this.state.fromSearch}
useMilitaryTime={this.state.useMilitaryTime} isWebrtc={WebrtcStore.isBusy()}
toggleSize={this.toggleSize} isMentionSearch={this.state.isMentionSearch}
shrink={this.onShrink} currentUser={this.state.currentUser}
/> useMilitaryTime={this.state.useMilitaryTime}
toggleSize={this.toggleSize}
shrink={this.onShrink}
/>
</div>
); );
} }

Просмотреть файл

@@ -25,6 +25,7 @@ export default class SuggestionBox extends React.Component {
this.handleCompositionEnd = this.handleCompositionEnd.bind(this); this.handleCompositionEnd = this.handleCompositionEnd.bind(this);
this.handleKeyDown = this.handleKeyDown.bind(this); this.handleKeyDown = this.handleKeyDown.bind(this);
this.handlePretextChanged = this.handlePretextChanged.bind(this); this.handlePretextChanged = this.handlePretextChanged.bind(this);
this.blur = this.blur.bind(this);
this.suggestionId = Utils.generateId(); this.suggestionId = Utils.generateId();
SuggestionStore.registerSuggestionBox(this.suggestionId); SuggestionStore.registerSuggestionBox(this.suggestionId);
@@ -189,6 +190,10 @@ export default class SuggestionBox extends React.Component {
} }
} }
blur() {
this.refs.textbox.blur();
}
render() { render() {
const { const {
type, type,