diff --git a/app/components/autocomplete/at_mention/at_mention.js b/app/components/autocomplete/at_mention/at_mention.js index c3b0d0de0..c8478c2ae 100644 --- a/app/components/autocomplete/at_mention/at_mention.js +++ b/app/components/autocomplete/at_mention/at_mention.js @@ -36,6 +36,7 @@ export default class AtMention extends PureComponent { theme: PropTypes.object.isRequired, value: PropTypes.string, isLandscape: PropTypes.bool.isRequired, + nestedScrollEnabled: PropTypes.bool, }; static defaultProps = { @@ -207,7 +208,7 @@ export default class AtMention extends PureComponent { }; render() { - const {maxListHeight, theme} = this.props; + const {maxListHeight, theme, nestedScrollEnabled} = this.props; const {mentionComplete, sections} = this.state; if (sections.length === 0 || mentionComplete) { @@ -228,6 +229,7 @@ export default class AtMention extends PureComponent { renderSectionHeader={this.renderSectionHeader} ItemSeparatorComponent={AutocompleteDivider} initialNumToRender={10} + nestedScrollEnabled={nestedScrollEnabled} /> ); } diff --git a/app/components/autocomplete/autocomplete.js b/app/components/autocomplete/autocomplete.js index b7e9dddd4..a2a8928fd 100644 --- a/app/components/autocomplete/autocomplete.js +++ b/app/components/autocomplete/autocomplete.js @@ -33,12 +33,14 @@ export default class Autocomplete extends PureComponent { enableDateSuggestion: PropTypes.bool.isRequired, valueEvent: PropTypes.string, cursorPositionEvent: PropTypes.string, + nestedScrollEnabled: PropTypes.bool, }; static defaultProps = { isSearch: false, cursorPosition: 0, enableDateSuggestion: false, + nestedScrollEnabled: false, }; static getDerivedStateFromProps(props, state) { @@ -191,6 +193,7 @@ export default class Autocomplete extends PureComponent { onChangeText={this.onChangeText} onResultCountChange={this.handleAtMentionCountChange} value={value || ''} + nestedScrollEnabled={this.props.nestedScrollEnabled} /> {(this.props.isSearch && this.props.enableDateSuggestion) && ); } diff --git a/app/components/autocomplete/emoji_suggestion/emoji_suggestion.js b/app/components/autocomplete/emoji_suggestion/emoji_suggestion.js index 8b33935e2..00cecd461 100644 --- a/app/components/autocomplete/emoji_suggestion/emoji_suggestion.js +++ b/app/components/autocomplete/emoji_suggestion/emoji_suggestion.js @@ -37,6 +37,7 @@ export default class EmojiSuggestion extends Component { rootId: PropTypes.string, value: PropTypes.string, serverVersion: PropTypes.string, + nestedScrollEnabled: PropTypes.bool, }; static defaultProps = { @@ -188,7 +189,7 @@ export default class EmojiSuggestion extends Component { getItemLayout = ({index}) => ({length: 40, offset: 40 * index, index}) render() { - const {maxListHeight, theme} = this.props; + const {maxListHeight, theme, nestedScrollEnabled} = this.props; if (!this.state.active) { // If we are not in an active state return null so nothing is rendered @@ -209,6 +210,7 @@ export default class EmojiSuggestion extends Component { ItemSeparatorComponent={AutocompleteDivider} pageSize={10} initialListSize={10} + nestedScrollEnabled={nestedScrollEnabled} /> ); } diff --git a/app/components/autocomplete/slash_suggestion/slash_suggestion.js b/app/components/autocomplete/slash_suggestion/slash_suggestion.js index bbf8c1da0..8af8a3f4e 100644 --- a/app/components/autocomplete/slash_suggestion/slash_suggestion.js +++ b/app/components/autocomplete/slash_suggestion/slash_suggestion.js @@ -33,6 +33,7 @@ export default class SlashSuggestion extends Component { onResultCountChange: PropTypes.func.isRequired, value: PropTypes.string, isLandscape: PropTypes.bool.isRequired, + nestedScrollEnabled: PropTypes.bool, }; static defaultProps = { @@ -151,7 +152,7 @@ export default class SlashSuggestion extends Component { ) render() { - const {maxListHeight, theme} = this.props; + const {maxListHeight, theme, nestedScrollEnabled} = this.props; if (!this.state.active) { // If we are not in an active state return null so nothing is rendered @@ -172,6 +173,7 @@ export default class SlashSuggestion extends Component { ItemSeparatorComponent={AutocompleteDivider} pageSize={10} initialListSize={10} + nestedScrollEnabled={nestedScrollEnabled} /> ); } diff --git a/app/components/edit_channel_info/edit_channel_info.js b/app/components/edit_channel_info/edit_channel_info.js index bcf2a9be8..5dede691f 100644 --- a/app/components/edit_channel_info/edit_channel_info.js +++ b/app/components/edit_channel_info/edit_channel_info.js @@ -14,6 +14,7 @@ import {KeyboardAwareScrollView} from 'react-native-keyboard-aware-scroll-view'; import {General} from 'mattermost-redux/constants'; +import Autocomplete from 'app/components/autocomplete'; import ErrorText from 'app/components/error_text'; import FormattedText from 'app/components/formatted_text'; import Loading from 'app/components/loading'; @@ -220,6 +221,7 @@ export default class EditChannelInfo extends PureComponent { {displayError} @@ -330,6 +332,13 @@ export default class EditChannelInfo extends PureComponent { defaultMessage='(optional)' /> + { + const baseProps = { + actions: { + dismissModal: jest.fn(), + popTopScreen: jest.fn(), + }, + theme: Preferences.THEMES.default, + deviceWidth: 400, + deviceHeight: 600, + channelType: 'O', + enableRightButton: jest.fn(), + saving: false, + editing: true, + error: '', + displayName: 'display_name', + currentTeamUrl: '/team_a', + channelURL: '/team_a/channels/channel_a', + purpose: 'purpose', + header: 'header', + onDisplayNameChange: jest.fn(), + onChannelURLChange: jest.fn(), + onPurposeChange: jest.fn(), + onHeaderChange: jest.fn(), + oldDisplayName: 'old_display_name', + oldChannelURL: '/team_a/channels/channel_old', + oldHeader: 'old_header', + oldPurpose: 'old_purpose', + isLandscape: true, + }; + + test('should have called onHeaderChangeText on text change from Autocomplete', () => { + const wrapper = shallow( + + ); + + const instance = wrapper.instance(); + instance.enableRightButton = jest.fn(); + + const autocomplete = wrapper.find(Autocomplete); + + expect(autocomplete.exists()).toEqual(true); + expect(autocomplete.props().value).toEqual('header'); + expect(autocomplete.props().cursorPosition).toEqual(6); + expect(autocomplete.props().nestedScrollEnabled).toEqual(true); + + autocomplete.props().onChangeText('header'); + expect(baseProps.onHeaderChange).toHaveBeenCalledTimes(1); + expect(baseProps.onHeaderChange).toHaveBeenCalledWith('header'); + expect(instance.enableRightButton).toHaveBeenCalledTimes(1); + expect(instance.enableRightButton).toHaveBeenCalledWith(true); + }); +}); \ No newline at end of file diff --git a/app/screens/channel_info/channel_info.js b/app/screens/channel_info/channel_info.js index d023aa688..07d5fc4b1 100644 --- a/app/screens/channel_info/channel_info.js +++ b/app/screens/channel_info/channel_info.js @@ -493,6 +493,7 @@ export default class ChannelInfo extends PureComponent { theme, isBot, isLandscape, + actions: {popToRoot}, } = this.props; const style = getStyleSheet(theme); @@ -533,6 +534,7 @@ export default class ChannelInfo extends PureComponent { isBot={isBot} hasGuests={currentChannelGuestCount > 0} isGroupConstrained={currentChannel.group_constrained} + popToRoot={popToRoot} /> } diff --git a/app/screens/channel_info/channel_info_header.js b/app/screens/channel_info/channel_info_header.js index 053495368..cf607b4a6 100644 --- a/app/screens/channel_info/channel_info_header.js +++ b/app/screens/channel_info/channel_info_header.js @@ -42,6 +42,7 @@ export default class ChannelInfoHeader extends React.PureComponent { hasGuests: PropTypes.bool.isRequired, isGroupConstrained: PropTypes.bool, timeZone: PropTypes.string, + popToRoot: PropTypes.func, }; static contextTypes = { @@ -137,6 +138,7 @@ export default class ChannelInfoHeader extends React.PureComponent { isBot, isGroupConstrained, timeZone, + popToRoot, } = this.props; const style = getStyleSheet(theme); @@ -210,6 +212,7 @@ export default class ChannelInfoHeader extends React.PureComponent { textStyles={textStyles} blockStyles={blockStyles} value={header} + onChannelLinkPress={popToRoot} /> diff --git a/app/screens/channel_info/index.js b/app/screens/channel_info/index.js index 81be9d9d9..74a558da9 100644 --- a/app/screens/channel_info/index.js +++ b/app/screens/channel_info/index.js @@ -35,6 +35,7 @@ import {getUserCurrentTimezone} from 'mattermost-redux/utils/timezone_utils'; import { popTopScreen, goToScreen, + popToRoot, dismissModal, showModalOverCurrentContext, } from 'app/actions/navigation'; @@ -146,6 +147,7 @@ function mapDispatchToProps(dispatch) { handleSelectChannel, popTopScreen, goToScreen, + popToRoot, dismissModal, showModalOverCurrentContext, }, dispatch),