Added auto-focus of content warning input box when CW button clicked
Removed spoilerActive prop and used existing spoiler prop Fixed linter issue and removed commented code
This commit is contained in:
parent
6f76e1796b
commit
84ba6a0cc3
2 changed files with 10 additions and 1 deletions
|
@ -153,6 +153,12 @@ export default class AutosuggestInput extends ImmutablePureComponent {
|
||||||
this.input.focus();
|
this.input.focus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
componentDidUpdate() {
|
||||||
|
if (this.props.autoFocus) {
|
||||||
|
this.input.focus();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
componentWillReceiveProps(nextProps) {
|
componentWillReceiveProps(nextProps) {
|
||||||
if (nextProps.suggestions !== this.props.suggestions && nextProps.suggestions.size > 0 && this.state.suggestionsHidden && this.state.focused) {
|
if (nextProps.suggestions !== this.props.suggestions && nextProps.suggestions.size > 0 && this.state.suggestionsHidden && this.state.focused) {
|
||||||
this.setState({ suggestionsHidden: false });
|
this.setState({ suggestionsHidden: false });
|
||||||
|
|
|
@ -32,6 +32,7 @@ const messages = defineMessages({
|
||||||
});
|
});
|
||||||
|
|
||||||
export default @injectIntl
|
export default @injectIntl
|
||||||
|
|
||||||
class ComposeForm extends ImmutablePureComponent {
|
class ComposeForm extends ImmutablePureComponent {
|
||||||
|
|
||||||
state = {
|
state = {
|
||||||
|
@ -197,12 +198,13 @@ class ComposeForm extends ImmutablePureComponent {
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { intl, onPaste, showSearch, anyMedia, shouldCondense, autoFocus, isModalOpen, maxTootChars } = this.props;
|
const { intl, onPaste, showSearch, anyMedia, shouldCondense, autoFocus, spoiler, isModalOpen, maxTootChars } = this.props;
|
||||||
const condensed = shouldCondense && !this.props.text && !this.state.composeFocused;
|
const condensed = shouldCondense && !this.props.text && !this.state.composeFocused;
|
||||||
const disabled = this.props.isSubmitting;
|
const disabled = this.props.isSubmitting;
|
||||||
const text = [this.props.spoilerText, countableText(this.props.text)].join('');
|
const text = [this.props.spoilerText, countableText(this.props.text)].join('');
|
||||||
const disabledButton = disabled || this.props.isUploading || this.props.isChangingUpload || length(text) > maxTootChars || (text.length !== 0 && text.trim().length === 0 && !anyMedia);
|
const disabledButton = disabled || this.props.isUploading || this.props.isChangingUpload || length(text) > maxTootChars || (text.length !== 0 && text.trim().length === 0 && !anyMedia);
|
||||||
const shouldAutoFocus = autoFocus && !showSearch && !isMobile(window.innerWidth);
|
const shouldAutoFocus = autoFocus && !showSearch && !isMobile(window.innerWidth);
|
||||||
|
const shouldSpoilerAutoFocus = spoiler && !showSearch && !isMobile(window.innerWidth);
|
||||||
|
|
||||||
let publishText = '';
|
let publishText = '';
|
||||||
|
|
||||||
|
@ -235,6 +237,7 @@ class ComposeForm extends ImmutablePureComponent {
|
||||||
onSuggestionsFetchRequested={this.onSuggestionsFetchRequested}
|
onSuggestionsFetchRequested={this.onSuggestionsFetchRequested}
|
||||||
onSuggestionsClearRequested={this.onSuggestionsClearRequested}
|
onSuggestionsClearRequested={this.onSuggestionsClearRequested}
|
||||||
onSuggestionSelected={this.onSpoilerSuggestionSelected}
|
onSuggestionSelected={this.onSpoilerSuggestionSelected}
|
||||||
|
autoFocus={shouldSpoilerAutoFocus}
|
||||||
searchTokens={[':']}
|
searchTokens={[':']}
|
||||||
id='cw-spoiler-input'
|
id='cw-spoiler-input'
|
||||||
className='spoiler-input__input'
|
className='spoiler-input__input'
|
||||||
|
|
Loading…
Reference in a new issue