diff --git a/app/javascript/mastodon/components/__tests__/__snapshots__/button-test.js.snap b/app/javascript/mastodon/components/__tests__/__snapshots__/button-test.js.snap index 86fbba917..bfc091d45 100644 --- a/app/javascript/mastodon/components/__tests__/__snapshots__/button-test.js.snap +++ b/app/javascript/mastodon/components/__tests__/__snapshots__/button-test.js.snap @@ -4,6 +4,7 @@ exports[` adds class "button-secondary" if props.secondary given 1`] = `; @@ -11,6 +12,7 @@ exports[` renders a button element 1`] = ` `; @@ -19,6 +21,7 @@ exports[` renders a disabled attribute if props.disabled given 1`] = ` className="button" disabled={true} onClick={[Function]} + type="button" /> `; @@ -26,6 +29,7 @@ exports[` renders class="button--block" if props.block given 1`] = ` `; @@ -33,6 +37,7 @@ exports[` renders the children 1`] = ` children @@ -44,6 +49,7 @@ exports[` renders the given text 1`] = ` foo @@ -53,6 +59,7 @@ exports[` renders the props.text instead of children 1`] = ` foo diff --git a/app/javascript/mastodon/components/button.js b/app/javascript/mastodon/components/button.js index bcb855c7c..42ce01f38 100644 --- a/app/javascript/mastodon/components/button.js +++ b/app/javascript/mastodon/components/button.js @@ -16,8 +16,12 @@ export default class Button extends React.PureComponent { children: PropTypes.node, }; + static defaultProps = { + type: 'button', + }; + handleClick = (e) => { - if (!this.props.disabled) { + if (!this.props.disabled && this.props.onClick) { this.props.onClick(e); } } diff --git a/app/javascript/mastodon/components/icon_button.js b/app/javascript/mastodon/components/icon_button.js index 47945c475..8fd9e10c0 100644 --- a/app/javascript/mastodon/components/icon_button.js +++ b/app/javascript/mastodon/components/icon_button.js @@ -141,6 +141,7 @@ export default class IconButton extends React.PureComponent { return ( + ); diff --git a/app/javascript/mastodon/features/compose/components/compose_form.js b/app/javascript/mastodon/features/compose/components/compose_form.js index 9f5c3b314..6a65f44da 100644 --- a/app/javascript/mastodon/features/compose/components/compose_form.js +++ b/app/javascript/mastodon/features/compose/components/compose_form.js @@ -93,7 +93,7 @@ class ComposeForm extends ImmutablePureComponent { return !(isSubmitting || isUploading || isChangingUpload || length(fulltext) > 500 || (isOnlyWhitespace && !anyMedia)); } - handleSubmit = () => { + handleSubmit = (e) => { if (this.props.text !== this.autosuggestTextarea.textarea.value) { // Something changed the text inside the textarea (e.g. browser extensions like Grammarly) // Update the state to match the current text @@ -105,6 +105,10 @@ class ComposeForm extends ImmutablePureComponent { } this.props.onSubmit(this.context.router ? this.context.router.history : null); + + if (e) { + e.preventDefault(); + } } onSuggestionsClearRequested = () => { @@ -217,7 +221,7 @@ class ComposeForm extends ImmutablePureComponent { } return ( - + @@ -280,9 +284,8 @@ class ComposeForm extends ImmutablePureComponent { diff --git a/app/javascript/mastodon/features/compose/components/emoji_picker_dropdown.js b/app/javascript/mastodon/features/compose/components/emoji_picker_dropdown.js index f433e4de9..8cca8af2a 100644 --- a/app/javascript/mastodon/features/compose/components/emoji_picker_dropdown.js +++ b/app/javascript/mastodon/features/compose/components/emoji_picker_dropdown.js @@ -96,12 +96,12 @@ class ModifierPickerMenu extends React.PureComponent { return ( - - - - - - + + + + + + ); } diff --git a/app/javascript/mastodon/features/compose/components/language_dropdown.js b/app/javascript/mastodon/features/compose/components/language_dropdown.js index 0af3db7a4..e48fa60ff 100644 --- a/app/javascript/mastodon/features/compose/components/language_dropdown.js +++ b/app/javascript/mastodon/features/compose/components/language_dropdown.js @@ -227,7 +227,7 @@ class LanguageDropdownMenu extends React.PureComponent { - {!isSearching ? loupeIcon : deleteIcon} + {!isSearching ? loupeIcon : deleteIcon} diff --git a/app/javascript/mastodon/features/compose/components/poll_form.js b/app/javascript/mastodon/features/compose/components/poll_form.js index db49f90eb..ede29b8a0 100644 --- a/app/javascript/mastodon/features/compose/components/poll_form.js +++ b/app/javascript/mastodon/features/compose/components/poll_form.js @@ -157,7 +157,7 @@ class PollForm extends ImmutablePureComponent { - = 4} className='button button-secondary' onClick={this.handleAddOption}> + = 4} className='button button-secondary' onClick={this.handleAddOption}> {/* eslint-disable-next-line jsx-a11y/no-onchange */} diff --git a/app/javascript/mastodon/features/compose/components/text_icon_button.js b/app/javascript/mastodon/features/compose/components/text_icon_button.js index cd644b680..73da32ad5 100644 --- a/app/javascript/mastodon/features/compose/components/text_icon_button.js +++ b/app/javascript/mastodon/features/compose/components/text_icon_button.js @@ -22,6 +22,7 @@ export default class TextIconButton extends React.PureComponent { return ( ( - - {!isEditingStatus && ( )} + + {!isEditingStatus && ( )} {(media.get('description') || '').length === 0 && ( - + )} diff --git a/app/javascript/mastodon/features/favourites/index.js b/app/javascript/mastodon/features/favourites/index.js index ad10744da..66ec6a31b 100644 --- a/app/javascript/mastodon/features/favourites/index.js +++ b/app/javascript/mastodon/features/favourites/index.js @@ -68,7 +68,7 @@ class Favourites extends ImmutablePureComponent { showBackButton multiColumn={multiColumn} extraButton={( - + )} /> diff --git a/app/javascript/mastodon/features/filters/select_filter.js b/app/javascript/mastodon/features/filters/select_filter.js index b5b354529..b68a5de6c 100644 --- a/app/javascript/mastodon/features/filters/select_filter.js +++ b/app/javascript/mastodon/features/filters/select_filter.js @@ -177,7 +177,7 @@ class SelectFilter extends React.PureComponent { - {!isSearching ? loupeIcon : deleteIcon} + {!isSearching ? loupeIcon : deleteIcon} diff --git a/app/javascript/mastodon/features/home_timeline/index.js b/app/javascript/mastodon/features/home_timeline/index.js index 838ed7dd8..749a47e76 100644 --- a/app/javascript/mastodon/features/home_timeline/index.js +++ b/app/javascript/mastodon/features/home_timeline/index.js @@ -126,6 +126,7 @@ class HomeTimeline extends React.PureComponent { if (hasAnnouncements) { announcementsButton = ( - + - + diff --git a/app/javascript/mastodon/features/reblogs/index.js b/app/javascript/mastodon/features/reblogs/index.js index 70d338ef1..36ca11d1a 100644 --- a/app/javascript/mastodon/features/reblogs/index.js +++ b/app/javascript/mastodon/features/reblogs/index.js @@ -68,7 +68,7 @@ class Reblogs extends ImmutablePureComponent { showBackButton multiColumn={multiColumn} extraButton={( - + )} /> diff --git a/app/javascript/mastodon/features/status/components/card.js b/app/javascript/mastodon/features/status/components/card.js index 3d81bcb29..82537dd5d 100644 --- a/app/javascript/mastodon/features/status/components/card.js +++ b/app/javascript/mastodon/features/status/components/card.js @@ -247,7 +247,7 @@ export default class Card extends React.PureComponent { {revealed && ( - + {horizontal && } diff --git a/app/javascript/mastodon/features/status/index.js b/app/javascript/mastodon/features/status/index.js index 02f390c6a..c0ba1f2d6 100644 --- a/app/javascript/mastodon/features/status/index.js +++ b/app/javascript/mastodon/features/status/index.js @@ -619,7 +619,7 @@ class Status extends ImmutablePureComponent { showBackButton multiColumn={multiColumn} extraButton={( - + )} />
children @@ -44,6 +49,7 @@ exports[` renders the given text 1`] = ` foo @@ -53,6 +59,7 @@ exports[` renders the props.text instead of children 1`] = ` foo diff --git a/app/javascript/mastodon/components/button.js b/app/javascript/mastodon/components/button.js index bcb855c7c..42ce01f38 100644 --- a/app/javascript/mastodon/components/button.js +++ b/app/javascript/mastodon/components/button.js @@ -16,8 +16,12 @@ export default class Button extends React.PureComponent { children: PropTypes.node, }; + static defaultProps = { + type: 'button', + }; + handleClick = (e) => { - if (!this.props.disabled) { + if (!this.props.disabled && this.props.onClick) { this.props.onClick(e); } } diff --git a/app/javascript/mastodon/components/icon_button.js b/app/javascript/mastodon/components/icon_button.js index 47945c475..8fd9e10c0 100644 --- a/app/javascript/mastodon/components/icon_button.js +++ b/app/javascript/mastodon/components/icon_button.js @@ -141,6 +141,7 @@ export default class IconButton extends React.PureComponent { return ( + ); diff --git a/app/javascript/mastodon/features/compose/components/compose_form.js b/app/javascript/mastodon/features/compose/components/compose_form.js index 9f5c3b314..6a65f44da 100644 --- a/app/javascript/mastodon/features/compose/components/compose_form.js +++ b/app/javascript/mastodon/features/compose/components/compose_form.js @@ -93,7 +93,7 @@ class ComposeForm extends ImmutablePureComponent { return !(isSubmitting || isUploading || isChangingUpload || length(fulltext) > 500 || (isOnlyWhitespace && !anyMedia)); } - handleSubmit = () => { + handleSubmit = (e) => { if (this.props.text !== this.autosuggestTextarea.textarea.value) { // Something changed the text inside the textarea (e.g. browser extensions like Grammarly) // Update the state to match the current text @@ -105,6 +105,10 @@ class ComposeForm extends ImmutablePureComponent { } this.props.onSubmit(this.context.router ? this.context.router.history : null); + + if (e) { + e.preventDefault(); + } } onSuggestionsClearRequested = () => { @@ -217,7 +221,7 @@ class ComposeForm extends ImmutablePureComponent { } return ( - + @@ -280,9 +284,8 @@ class ComposeForm extends ImmutablePureComponent { diff --git a/app/javascript/mastodon/features/compose/components/emoji_picker_dropdown.js b/app/javascript/mastodon/features/compose/components/emoji_picker_dropdown.js index f433e4de9..8cca8af2a 100644 --- a/app/javascript/mastodon/features/compose/components/emoji_picker_dropdown.js +++ b/app/javascript/mastodon/features/compose/components/emoji_picker_dropdown.js @@ -96,12 +96,12 @@ class ModifierPickerMenu extends React.PureComponent { return ( - - - - - - + + + + + + ); } diff --git a/app/javascript/mastodon/features/compose/components/language_dropdown.js b/app/javascript/mastodon/features/compose/components/language_dropdown.js index 0af3db7a4..e48fa60ff 100644 --- a/app/javascript/mastodon/features/compose/components/language_dropdown.js +++ b/app/javascript/mastodon/features/compose/components/language_dropdown.js @@ -227,7 +227,7 @@ class LanguageDropdownMenu extends React.PureComponent { - {!isSearching ? loupeIcon : deleteIcon} + {!isSearching ? loupeIcon : deleteIcon} diff --git a/app/javascript/mastodon/features/compose/components/poll_form.js b/app/javascript/mastodon/features/compose/components/poll_form.js index db49f90eb..ede29b8a0 100644 --- a/app/javascript/mastodon/features/compose/components/poll_form.js +++ b/app/javascript/mastodon/features/compose/components/poll_form.js @@ -157,7 +157,7 @@ class PollForm extends ImmutablePureComponent { - = 4} className='button button-secondary' onClick={this.handleAddOption}> + = 4} className='button button-secondary' onClick={this.handleAddOption}> {/* eslint-disable-next-line jsx-a11y/no-onchange */} diff --git a/app/javascript/mastodon/features/compose/components/text_icon_button.js b/app/javascript/mastodon/features/compose/components/text_icon_button.js index cd644b680..73da32ad5 100644 --- a/app/javascript/mastodon/features/compose/components/text_icon_button.js +++ b/app/javascript/mastodon/features/compose/components/text_icon_button.js @@ -22,6 +22,7 @@ export default class TextIconButton extends React.PureComponent { return ( ( - - {!isEditingStatus && ( )} + + {!isEditingStatus && ( )} {(media.get('description') || '').length === 0 && ( - + )} diff --git a/app/javascript/mastodon/features/favourites/index.js b/app/javascript/mastodon/features/favourites/index.js index ad10744da..66ec6a31b 100644 --- a/app/javascript/mastodon/features/favourites/index.js +++ b/app/javascript/mastodon/features/favourites/index.js @@ -68,7 +68,7 @@ class Favourites extends ImmutablePureComponent { showBackButton multiColumn={multiColumn} extraButton={( - + )} /> diff --git a/app/javascript/mastodon/features/filters/select_filter.js b/app/javascript/mastodon/features/filters/select_filter.js index b5b354529..b68a5de6c 100644 --- a/app/javascript/mastodon/features/filters/select_filter.js +++ b/app/javascript/mastodon/features/filters/select_filter.js @@ -177,7 +177,7 @@ class SelectFilter extends React.PureComponent { - {!isSearching ? loupeIcon : deleteIcon} + {!isSearching ? loupeIcon : deleteIcon} diff --git a/app/javascript/mastodon/features/home_timeline/index.js b/app/javascript/mastodon/features/home_timeline/index.js index 838ed7dd8..749a47e76 100644 --- a/app/javascript/mastodon/features/home_timeline/index.js +++ b/app/javascript/mastodon/features/home_timeline/index.js @@ -126,6 +126,7 @@ class HomeTimeline extends React.PureComponent { if (hasAnnouncements) { announcementsButton = ( - + - + diff --git a/app/javascript/mastodon/features/reblogs/index.js b/app/javascript/mastodon/features/reblogs/index.js index 70d338ef1..36ca11d1a 100644 --- a/app/javascript/mastodon/features/reblogs/index.js +++ b/app/javascript/mastodon/features/reblogs/index.js @@ -68,7 +68,7 @@ class Reblogs extends ImmutablePureComponent { showBackButton multiColumn={multiColumn} extraButton={( - + )} /> diff --git a/app/javascript/mastodon/features/status/components/card.js b/app/javascript/mastodon/features/status/components/card.js index 3d81bcb29..82537dd5d 100644 --- a/app/javascript/mastodon/features/status/components/card.js +++ b/app/javascript/mastodon/features/status/components/card.js @@ -247,7 +247,7 @@ export default class Card extends React.PureComponent { {revealed && ( - + {horizontal && } diff --git a/app/javascript/mastodon/features/status/index.js b/app/javascript/mastodon/features/status/index.js index 02f390c6a..c0ba1f2d6 100644 --- a/app/javascript/mastodon/features/status/index.js +++ b/app/javascript/mastodon/features/status/index.js @@ -619,7 +619,7 @@ class Status extends ImmutablePureComponent { showBackButton multiColumn={multiColumn} extraButton={( - + )} />