From 83a8efa9cad7384e6659bd6c17e4865405f51577 Mon Sep 17 00:00:00 2001 From: Claire Date: Tue, 24 Jan 2023 18:49:21 +0100 Subject: Add lang attribute to compose textarea and CW field (#23240) Fixes #19858 --- app/javascript/mastodon/components/autosuggest_input.js | 4 +++- app/javascript/mastodon/components/autosuggest_textarea.js | 4 +++- app/javascript/mastodon/features/compose/components/compose_form.js | 3 +++ .../mastodon/features/compose/containers/compose_form_container.js | 1 + 4 files changed, 10 insertions(+), 2 deletions(-) (limited to 'app/javascript') diff --git a/app/javascript/mastodon/components/autosuggest_input.js b/app/javascript/mastodon/components/autosuggest_input.js index 12d44b5d0..b8f8c6f45 100644 --- a/app/javascript/mastodon/components/autosuggest_input.js +++ b/app/javascript/mastodon/components/autosuggest_input.js @@ -50,6 +50,7 @@ export default class AutosuggestInput extends ImmutablePureComponent { id: PropTypes.string, searchTokens: PropTypes.arrayOf(PropTypes.string), maxLength: PropTypes.number, + lang: PropTypes.string, }; static defaultProps = { @@ -185,7 +186,7 @@ export default class AutosuggestInput extends ImmutablePureComponent { } render () { - const { value, suggestions, disabled, placeholder, onKeyUp, autoFocus, className, id, maxLength } = this.props; + const { value, suggestions, disabled, placeholder, onKeyUp, autoFocus, className, id, maxLength, lang } = this.props; const { suggestionsHidden } = this.state; return ( @@ -210,6 +211,7 @@ export default class AutosuggestInput extends ImmutablePureComponent { id={id} className={className} maxLength={maxLength} + lang={lang} /> diff --git a/app/javascript/mastodon/components/autosuggest_textarea.js b/app/javascript/mastodon/components/autosuggest_textarea.js index 08b9cd80b..b6c590916 100644 --- a/app/javascript/mastodon/components/autosuggest_textarea.js +++ b/app/javascript/mastodon/components/autosuggest_textarea.js @@ -48,6 +48,7 @@ export default class AutosuggestTextarea extends ImmutablePureComponent { onKeyDown: PropTypes.func, onPaste: PropTypes.func.isRequired, autoFocus: PropTypes.bool, + lang: PropTypes.string, }; static defaultProps = { @@ -192,7 +193,7 @@ export default class AutosuggestTextarea extends ImmutablePureComponent { } render () { - const { value, suggestions, disabled, placeholder, onKeyUp, autoFocus, children } = this.props; + const { value, suggestions, disabled, placeholder, onKeyUp, autoFocus, lang, children } = this.props; const { suggestionsHidden } = this.state; return [ @@ -216,6 +217,7 @@ export default class AutosuggestTextarea extends ImmutablePureComponent { onPaste={this.onPaste} dir='auto' aria-autocomplete='list' + lang={lang} /> diff --git a/app/javascript/mastodon/features/compose/components/compose_form.js b/app/javascript/mastodon/features/compose/components/compose_form.js index fc2eefa45..7154c5efc 100644 --- a/app/javascript/mastodon/features/compose/components/compose_form.js +++ b/app/javascript/mastodon/features/compose/components/compose_form.js @@ -64,6 +64,7 @@ class ComposeForm extends ImmutablePureComponent { anyMedia: PropTypes.bool, isInReply: PropTypes.bool, singleColumn: PropTypes.bool, + lang: PropTypes.string, }; static defaultProps = { @@ -240,6 +241,7 @@ class ComposeForm extends ImmutablePureComponent { searchTokens={[':']} id='cw-spoiler-input' className='spoiler-input__input' + lang={this.props.lang} /> @@ -257,6 +259,7 @@ class ComposeForm extends ImmutablePureComponent { onSuggestionSelected={this.onSuggestionSelected} onPaste={onPaste} autoFocus={autoFocus} + lang={this.props.lang} > diff --git a/app/javascript/mastodon/features/compose/containers/compose_form_container.js b/app/javascript/mastodon/features/compose/containers/compose_form_container.js index 14cf9230b..2b7642237 100644 --- a/app/javascript/mastodon/features/compose/containers/compose_form_container.js +++ b/app/javascript/mastodon/features/compose/containers/compose_form_container.js @@ -26,6 +26,7 @@ const mapStateToProps = state => ({ isUploading: state.getIn(['compose', 'is_uploading']), anyMedia: state.getIn(['compose', 'media_attachments']).size > 0, isInReply: state.getIn(['compose', 'in_reply_to']) !== null, + lang: state.getIn(['compose', 'language']), }); const mapDispatchToProps = (dispatch) => ({ -- cgit