From de74acbe0c24f3e8198de514dc00201e93d6d212 Mon Sep 17 00:00:00 2001 From: Claire Date: Sun, 7 May 2023 21:43:25 +0200 Subject: [PATCH] Fix some more Javascript linting issues and discrepancies with upstream (#2209) * Fix typo in flavours/glitch/features/video/index.js * Fix various linting issues and discrepancies with upstream --- app/javascript/core/public.js | 2 - .../flavours/glitch/actions/accounts.js | 2 +- .../flavours/glitch/actions/timelines.js | 11 ++-- .../glitch/components/avatar_composite.jsx | 1 + .../glitch/components/display_name.jsx | 2 + .../glitch/components/icon_button.jsx | 7 ++- .../glitch/components/media_gallery.jsx | 4 +- .../flavours/glitch/components/spoilers.jsx | 52 ------------------- .../flavours/glitch/components/status.jsx | 9 ++-- .../glitch/components/status_header.jsx | 1 - .../glitch/components/status_icons.jsx | 21 ++++---- .../glitch/containers/domain_container.jsx | 3 +- .../glitch/containers/status_container.js | 7 +-- .../account/components/action_bar.jsx | 11 ++-- .../glitch/features/account_gallery/index.jsx | 3 +- .../containers/header_container.jsx | 4 -- .../features/account_timeline/index.jsx | 1 - .../flavours/glitch/features/audio/index.jsx | 2 +- .../compose/components/compose_form.jsx | 24 ++++----- .../features/compose/components/dropdown.jsx | 9 ++-- .../compose/components/dropdown_menu.jsx | 10 ++-- .../features/compose/components/poll_form.jsx | 1 + .../compose/components/privacy_dropdown.jsx | 1 - .../features/compose/components/search.jsx | 4 +- .../features/compose/components/upload.jsx | 1 - .../glitch/features/compose/index.jsx | 5 +- .../glitch/features/getting_started/index.jsx | 7 +-- .../features/getting_started_misc/index.jsx | 4 +- .../containers/account_container.js | 1 - .../containers/search_container.js | 1 - .../glitch/features/list_timeline/index.jsx | 10 ++-- .../page/deprecated_item/index.jsx | 2 +- .../local_settings/page/item/index.jsx | 5 +- .../notifications/components/admin_report.jsx | 9 +--- .../containers/follow_request_container.js | 1 - .../glitch/features/notifications/index.jsx | 45 ++++++---------- .../containers/account_container.js | 1 - .../containers/search_container.js | 1 - .../flavours/glitch/features/video/index.jsx | 2 +- 39 files changed, 87 insertions(+), 200 deletions(-) delete mode 100644 app/javascript/flavours/glitch/components/spoilers.jsx diff --git a/app/javascript/core/public.js b/app/javascript/core/public.js index 5c7a51f447..4fdda5c3e6 100644 --- a/app/javascript/core/public.js +++ b/app/javascript/core/public.js @@ -1,10 +1,8 @@ // This file will be loaded on public pages, regardless of theme. import 'packs/public-path'; -import ready from '../mastodon/ready'; const { delegate } = require('@rails/ujs'); -const { length } = require('stringz'); const getProfileAvatarAnimationHandler = (swapTo) => { //animate avatar gifs on the profile page when moused over diff --git a/app/javascript/flavours/glitch/actions/accounts.js b/app/javascript/flavours/glitch/actions/accounts.js index 6b5b2ade5c..92442ff596 100644 --- a/app/javascript/flavours/glitch/actions/accounts.js +++ b/app/javascript/flavours/glitch/actions/accounts.js @@ -1,5 +1,5 @@ import api, { getLinks } from '../api'; -import { importAccount, importFetchedAccount, importFetchedAccounts } from './importer'; +import { importFetchedAccount, importFetchedAccounts } from './importer'; export const ACCOUNT_FETCH_REQUEST = 'ACCOUNT_FETCH_REQUEST'; export const ACCOUNT_FETCH_SUCCESS = 'ACCOUNT_FETCH_SUCCESS'; diff --git a/app/javascript/flavours/glitch/actions/timelines.js b/app/javascript/flavours/glitch/actions/timelines.js index eb817daf9e..bde96c504b 100644 --- a/app/javascript/flavours/glitch/actions/timelines.js +++ b/app/javascript/flavours/glitch/actions/timelines.js @@ -3,7 +3,7 @@ import { submitMarkers } from './markers'; import api, { getLinks } from 'flavours/glitch/api'; import { Map as ImmutableMap, List as ImmutableList } from 'immutable'; import compareId from 'flavours/glitch/compare_id'; -import { me, usePendingItems as preferPendingItems } from 'flavours/glitch/initial_state'; +import { usePendingItems as preferPendingItems } from 'flavours/glitch/initial_state'; import { toServerSideType } from 'flavours/glitch/utils/filters'; export const TIMELINE_UPDATE = 'TIMELINE_UPDATE'; @@ -121,7 +121,6 @@ export function expandTimeline(timelineId, path, params = {}, done = noOp) { api(getState).get(path, { params }).then(response => { const next = getLinks(response).refs.find(link => link.rel === 'next'); - dispatch(importFetchedStatuses(response.data)); dispatch(expandTimelineSuccess(timelineId, response.data, next ? next.uri : null, response.status === 206, isLoadingRecent, isLoadingMore, isLoadingRecent && preferPendingItems)); @@ -163,10 +162,10 @@ export const expandListTimeline = (id, { maxId } = {}, done = noOp) = export const expandHashtagTimeline = (hashtag, { maxId, tags, local } = {}, done = noOp) => { return expandTimeline(`hashtag:${hashtag}${local ? ':local' : ''}`, `/api/v1/timelines/tag/${hashtag}`, { max_id: maxId, - any: parseTags(tags, 'any'), - all: parseTags(tags, 'all'), - none: parseTags(tags, 'none'), - local: local, + any: parseTags(tags, 'any'), + all: parseTags(tags, 'all'), + none: parseTags(tags, 'none'), + local: local, }, done); }; diff --git a/app/javascript/flavours/glitch/components/avatar_composite.jsx b/app/javascript/flavours/glitch/components/avatar_composite.jsx index c0ce7761dc..98ea9d2728 100644 --- a/app/javascript/flavours/glitch/components/avatar_composite.jsx +++ b/app/javascript/flavours/glitch/components/avatar_composite.jsx @@ -9,6 +9,7 @@ export default class AvatarComposite extends React.PureComponent { accounts: ImmutablePropTypes.list.isRequired, animate: PropTypes.bool, size: PropTypes.number.isRequired, + onAccountClick: PropTypes.func.isRequired, }; static defaultProps = { diff --git a/app/javascript/flavours/glitch/components/display_name.jsx b/app/javascript/flavours/glitch/components/display_name.jsx index 19f63ec60c..f58a8df824 100644 --- a/app/javascript/flavours/glitch/components/display_name.jsx +++ b/app/javascript/flavours/glitch/components/display_name.jsx @@ -14,6 +14,7 @@ export default class DisplayName extends React.PureComponent { localDomain: PropTypes.string, others: ImmutablePropTypes.list, handleClick: PropTypes.func, + onAccountClick: PropTypes.func, }; handleMouseEnter = ({ currentTarget }) => { @@ -61,6 +62,7 @@ export default class DisplayName extends React.PureComponent { if (others && others.size > 0) { displayName = others.take(2).map(a => ( onAccountClick(a.get('acct'), e)} diff --git a/app/javascript/flavours/glitch/components/icon_button.jsx b/app/javascript/flavours/glitch/components/icon_button.jsx index 10d7926be5..93640dd0f2 100644 --- a/app/javascript/flavours/glitch/components/icon_button.jsx +++ b/app/javascript/flavours/glitch/components/icon_button.jsx @@ -1,6 +1,4 @@ import React from 'react'; -import Motion from '../features/ui/util/optional_motion'; -import spring from 'react-motion/lib/spring'; import PropTypes from 'prop-types'; import classNames from 'classnames'; import Icon from 'flavours/glitch/components/icon'; @@ -25,7 +23,7 @@ export default class IconButton extends React.PureComponent { inverted: PropTypes.bool, animate: PropTypes.bool, overlay: PropTypes.bool, - tabIndex: PropTypes.string, + tabIndex: PropTypes.number, label: PropTypes.string, counter: PropTypes.number, obfuscateCount: PropTypes.bool, @@ -39,7 +37,7 @@ export default class IconButton extends React.PureComponent { disabled: false, animate: false, overlay: false, - tabIndex: '0', + tabIndex: 0, ariaHidden: false, }; @@ -156,6 +154,7 @@ export default class IconButton extends React.PureComponent { return ( -

, -
- {children} -
, - ]); - } - -} - diff --git a/app/javascript/flavours/glitch/components/status.jsx b/app/javascript/flavours/glitch/components/status.jsx index 6f77fb16eb..a5843a4e54 100644 --- a/app/javascript/flavours/glitch/components/status.jsx +++ b/app/javascript/flavours/glitch/components/status.jsx @@ -282,7 +282,7 @@ class Status extends ImmutablePureComponent { // Hack to fix timeline jumps on second rendering when auto-collapsing // or on subsequent rendering when a preview card has been fetched - getSnapshotBeforeUpdate (prevProps, prevState) { + getSnapshotBeforeUpdate() { if (!this.props.getScrollPosition) return null; const { muted, hidden, status, settings } = this.props; @@ -297,7 +297,7 @@ class Status extends ImmutablePureComponent { } } - componentDidUpdate (prevProps, prevState, snapshot) { + componentDidUpdate(prevProps, prevState, snapshot) { if (snapshot !== null && this.props.updateScrollBottom && this.node.offsetTop < snapshot.top) { this.props.updateScrollBottom(snapshot.height - snapshot.top); } @@ -461,7 +461,7 @@ class Status extends ImmutablePureComponent { this.props.onMoveDown(this.props.containerId || this.props.id, e.target.getAttribute('data-featured')); }; - handleHotkeyCollapse = e => { + handleHotkeyCollapse = () => { if (!this.props.settings.getIn(['collapsed', 'enabled'])) return; @@ -505,7 +505,6 @@ class Status extends ImmutablePureComponent { const { handleRef, parseClick, - setExpansion, setCollapsed, } = this; const { router } = this.context; @@ -529,7 +528,7 @@ class Status extends ImmutablePureComponent { rootId, ...other } = this.props; - const { isCollapsed, forceFilter } = this.state; + const { isCollapsed } = this.state; let background = null; let attachments = null; diff --git a/app/javascript/flavours/glitch/components/status_header.jsx b/app/javascript/flavours/glitch/components/status_header.jsx index 21d8b42128..94c403f169 100644 --- a/app/javascript/flavours/glitch/components/status_header.jsx +++ b/app/javascript/flavours/glitch/components/status_header.jsx @@ -6,7 +6,6 @@ import ImmutablePropTypes from 'react-immutable-proptypes'; // Mastodon imports. import Avatar from './avatar'; import AvatarOverlay from './avatar_overlay'; -import AvatarComposite from './avatar_composite'; import DisplayName from './display_name'; export default class StatusHeader extends React.PureComponent { diff --git a/app/javascript/flavours/glitch/components/status_icons.jsx b/app/javascript/flavours/glitch/components/status_icons.jsx index 3baff2206a..dd63cbd21c 100644 --- a/app/javascript/flavours/glitch/components/status_icons.jsx +++ b/app/javascript/flavours/glitch/components/status_icons.jsx @@ -64,18 +64,15 @@ class StatusIcons extends React.PureComponent { mediaIconTitleText (mediaIcon) { const { intl } = this.props; - switch (mediaIcon) { - case 'link': - return intl.formatMessage(messages.previewCard); - case 'picture-o': - return intl.formatMessage(messages.pictures); - case 'tasks': - return intl.formatMessage(messages.poll); - case 'video-camera': - return intl.formatMessage(messages.video); - case 'music': - return intl.formatMessage(messages.audio); - } + const message = { + 'link': messages.previewCard, + 'picture-o': messages.pictures, + 'tasks': messages.poll, + 'video-camera': messages.video, + 'music': messages.audio, + }[mediaIcon]; + + return message && intl.formatMessage(message); } renderIcon (mediaIcon) { diff --git a/app/javascript/flavours/glitch/containers/domain_container.jsx b/app/javascript/flavours/glitch/containers/domain_container.jsx index e92e102ab1..8a8ba1df12 100644 --- a/app/javascript/flavours/glitch/containers/domain_container.jsx +++ b/app/javascript/flavours/glitch/containers/domain_container.jsx @@ -10,8 +10,7 @@ const messages = defineMessages({ }); const makeMapStateToProps = () => { - const mapStateToProps = (state, { }) => ({ - }); + const mapStateToProps = () => ({}); return mapStateToProps; }; diff --git a/app/javascript/flavours/glitch/containers/status_container.js b/app/javascript/flavours/glitch/containers/status_container.js index d05005e3bb..8f3fce0705 100644 --- a/app/javascript/flavours/glitch/containers/status_container.js +++ b/app/javascript/flavours/glitch/containers/status_container.js @@ -1,6 +1,5 @@ import { connect } from 'react-redux'; import Status from 'flavours/glitch/components/status'; -import { List as ImmutableList } from 'immutable'; import { makeGetStatus, makeGetPictureInPicture } from 'flavours/glitch/selectors'; import { replyCompose, @@ -37,13 +36,9 @@ import { initBoostModal } from 'flavours/glitch/actions/boosts'; import { openModal } from 'flavours/glitch/actions/modal'; import { deployPictureInPicture } from 'flavours/glitch/actions/picture_in_picture'; import { changeLocalSetting } from 'flavours/glitch/actions/local_settings'; -import { defineMessages, injectIntl, FormattedMessage } from 'react-intl'; +import { defineMessages, injectIntl } from 'react-intl'; import { boostModal, favouriteModal, deleteModal } from 'flavours/glitch/initial_state'; -import { filterEditLink } from 'flavours/glitch/utils/backend_links'; import { showAlertForError } from '../actions/alerts'; -import AccountContainer from 'flavours/glitch/containers/account_container'; -import Spoilers from '../components/spoilers'; -import Icon from 'flavours/glitch/components/icon'; const messages = defineMessages({ deleteConfirm: { id: 'confirmations.delete.confirm', defaultMessage: 'Delete' }, diff --git a/app/javascript/flavours/glitch/features/account/components/action_bar.jsx b/app/javascript/flavours/glitch/features/account/components/action_bar.jsx index e32bc01416..7026c9278d 100644 --- a/app/javascript/flavours/glitch/features/account/components/action_bar.jsx +++ b/app/javascript/flavours/glitch/features/account/components/action_bar.jsx @@ -1,18 +1,13 @@ import React from 'react'; import ImmutablePropTypes from 'react-immutable-proptypes'; -import PropTypes from 'prop-types'; -import DropdownMenuContainer from 'flavours/glitch/containers/dropdown_menu_container'; import { NavLink } from 'react-router-dom'; -import { injectIntl, FormattedMessage, FormattedNumber } from 'react-intl'; -import { me, isStaff } from 'flavours/glitch/initial_state'; -import { profileLink, accountAdminLink } from 'flavours/glitch/utils/backend_links'; +import { FormattedMessage, FormattedNumber } from 'react-intl'; import Icon from 'flavours/glitch/components/icon'; class ActionBar extends React.PureComponent { static propTypes = { account: ImmutablePropTypes.map.isRequired, - intl: PropTypes.object.isRequired, }; isStatusesPageActive = (match, location) => { @@ -23,7 +18,7 @@ class ActionBar extends React.PureComponent { }; render () { - const { account, intl } = this.props; + const { account } = this.props; if (account.get('suspended')) { return ( @@ -83,4 +78,4 @@ class ActionBar extends React.PureComponent { } -export default injectIntl(ActionBar); +export default ActionBar; diff --git a/app/javascript/flavours/glitch/features/account_gallery/index.jsx b/app/javascript/flavours/glitch/features/account_gallery/index.jsx index 685b606fae..b4fc8be721 100644 --- a/app/javascript/flavours/glitch/features/account_gallery/index.jsx +++ b/app/javascript/flavours/glitch/features/account_gallery/index.jsx @@ -14,6 +14,7 @@ import HeaderContainer from 'flavours/glitch/features/account_timeline/container import ScrollContainer from 'flavours/glitch/containers/scroll_container'; import LoadMore from 'flavours/glitch/components/load_more'; import { openModal } from 'flavours/glitch/actions/modal'; +import { FormattedMessage } from 'react-intl'; import { normalizeForLookup } from 'flavours/glitch/reducers/accounts_map'; import BundleColumnError from 'flavours/glitch/features/ui/components/bundle_column_error'; @@ -71,8 +72,8 @@ class AccountGallery extends ImmutablePureComponent { isLoading: PropTypes.bool, hasMore: PropTypes.bool, isAccount: PropTypes.bool, - multiColumn: PropTypes.bool, suspended: PropTypes.bool, + multiColumn: PropTypes.bool, }; state = { diff --git a/app/javascript/flavours/glitch/features/account_timeline/containers/header_container.jsx b/app/javascript/flavours/glitch/features/account_timeline/containers/header_container.jsx index 3ec47cf2fd..c5432c64f1 100644 --- a/app/javascript/flavours/glitch/features/account_timeline/containers/header_container.jsx +++ b/app/javascript/flavours/glitch/features/account_timeline/containers/header_container.jsx @@ -93,10 +93,6 @@ const mapDispatchToProps = (dispatch, { intl }) => ({ dispatch(directCompose(account, router)); }, - onDirect (account, router) { - dispatch(directCompose(account, router)); - }, - onReblogToggle (account) { if (account.getIn(['relationship', 'showing_reblogs'])) { dispatch(followAccount(account.get('id'), { reblogs: false })); diff --git a/app/javascript/flavours/glitch/features/account_timeline/index.jsx b/app/javascript/flavours/glitch/features/account_timeline/index.jsx index bc1adb1c40..87c8d74675 100644 --- a/app/javascript/flavours/glitch/features/account_timeline/index.jsx +++ b/app/javascript/flavours/glitch/features/account_timeline/index.jsx @@ -9,7 +9,6 @@ import LoadingIndicator from '../../components/loading_indicator'; import Column from '../ui/components/column'; import ProfileColumnHeader from 'flavours/glitch/features/account/components/profile_column_header'; import HeaderContainer from './containers/header_container'; -import ColumnBackButton from 'flavours/glitch/components/column_back_button'; import { List as ImmutableList } from 'immutable'; import ImmutablePureComponent from 'react-immutable-pure-component'; import { FormattedMessage } from 'react-intl'; diff --git a/app/javascript/flavours/glitch/features/audio/index.jsx b/app/javascript/flavours/glitch/features/audio/index.jsx index 556a74ac48..ba88427915 100644 --- a/app/javascript/flavours/glitch/features/audio/index.jsx +++ b/app/javascript/flavours/glitch/features/audio/index.jsx @@ -94,7 +94,7 @@ class Audio extends React.PureComponent { const width = this.player.offsetWidth; const height = this.props.fullscreen ? this.player.offsetHeight : (width / (16/9)); - if (width && width != this.state.containerWidth) { + if (width && width !== this.state.containerWidth) { if (this.props.cacheWidth) { this.props.cacheWidth(width); } diff --git a/app/javascript/flavours/glitch/features/compose/components/compose_form.jsx b/app/javascript/flavours/glitch/features/compose/components/compose_form.jsx index 973a17a1ae..77062b8136 100644 --- a/app/javascript/flavours/glitch/features/compose/components/compose_form.jsx +++ b/app/javascript/flavours/glitch/features/compose/components/compose_form.jsx @@ -1,4 +1,5 @@ import React from 'react'; +import CharacterCounter from './character_counter'; import ImmutablePropTypes from 'react-immutable-proptypes'; import PropTypes from 'prop-types'; import ReplyIndicatorContainer from '../containers/reply_indicator_container'; @@ -11,13 +12,12 @@ import UploadFormContainer from '../containers/upload_form_container'; import WarningContainer from '../containers/warning_container'; import { isMobile } from 'flavours/glitch/is_mobile'; import ImmutablePureComponent from 'react-immutable-pure-component'; +import { length } from 'stringz'; import { countableText } from '../util/counter'; +import { maxChars } from 'flavours/glitch/initial_state'; import OptionsContainer from '../containers/options_container'; import Publisher from './publisher'; import TextareaIcons from './textarea_icons'; -import { maxChars } from 'flavours/glitch/initial_state'; -import CharacterCounter from './character_counter'; -import { length } from 'stringz'; const messages = defineMessages({ placeholder: { id: 'compose_form.placeholder', defaultMessage: 'What is on your mind?' }, @@ -76,7 +76,6 @@ class ComposeForm extends ImmutablePureComponent { preselectOnReply: PropTypes.bool, onChangeSpoilerness: PropTypes.func, onChangeVisibility: PropTypes.func, - onPaste: PropTypes.func, onMediaDescriptionConfirm: PropTypes.func, }; @@ -164,11 +163,11 @@ class ComposeForm extends ImmutablePureComponent { }; // Selects a suggestion from the autofill. - onSuggestionSelected = (tokenStart, token, value) => { + handleSuggestionSelected = (tokenStart, token, value) => { this.props.onSuggestionSelected(tokenStart, token, value, ['text']); }; - onSpoilerSuggestionSelected = (tokenStart, token, value) => { + handleSpoilerSuggestionSelected = (tokenStart, token, value) => { this.props.onSuggestionSelected(tokenStart, token, value, ['spoiler_text']); }; @@ -177,7 +176,7 @@ class ComposeForm extends ImmutablePureComponent { this.handleSubmit(); } - if (e.keyCode == 13 && e.altKey) { + if (e.keyCode === 13 && e.altKey) { this.handleSecondarySubmit(); } }; @@ -281,9 +280,7 @@ class ComposeForm extends ImmutablePureComponent { const { handleEmojiPick, handleSecondarySubmit, - handleSelect, handleSubmit, - handleRefTextarea, } = this; const { advancedOptions, @@ -291,7 +288,6 @@ class ComposeForm extends ImmutablePureComponent { isSubmitting, layout, onChangeSpoilerness, - onChangeVisibility, onClearSuggestions, onFetchSuggestions, onPaste, @@ -322,10 +318,10 @@ class ComposeForm extends ImmutablePureComponent { onKeyDown={this.handleKeyDown} disabled={!spoiler} ref={this.handleRefSpoilerText} - suggestions={this.props.suggestions} + suggestions={suggestions} onSuggestionsFetchRequested={onFetchSuggestions} onSuggestionsClearRequested={onClearSuggestions} - onSuggestionSelected={this.onSpoilerSuggestionSelected} + onSuggestionSelected={this.handleSpoilerSuggestionSelected} searchTokens={[':']} id='glitch.composer.spoiler.input' className='spoiler-input__input' @@ -342,11 +338,11 @@ class ComposeForm extends ImmutablePureComponent { value={this.props.text} onChange={this.handleChange} onKeyDown={this.handleKeyDown} - suggestions={this.props.suggestions} + suggestions={suggestions} onFocus={this.handleFocus} onSuggestionsFetchRequested={onFetchSuggestions} onSuggestionsClearRequested={onClearSuggestions} - onSuggestionSelected={this.onSuggestionSelected} + onSuggestionSelected={this.handleSuggestionSelected} onPaste={onPaste} autoFocus={!showSearch && !isMobile(window.innerWidth, layout)} lang={this.props.lang} diff --git a/app/javascript/flavours/glitch/features/compose/components/dropdown.jsx b/app/javascript/flavours/glitch/features/compose/components/dropdown.jsx index fe4ab36f5c..d32f3572a5 100644 --- a/app/javascript/flavours/glitch/features/compose/components/dropdown.jsx +++ b/app/javascript/flavours/glitch/features/compose/components/dropdown.jsx @@ -8,9 +8,6 @@ import Overlay from 'react-overlays/Overlay'; import IconButton from 'flavours/glitch/components/icon_button'; import DropdownMenu from './dropdown_menu'; -// Utils. -import { assignHandlers } from 'flavours/glitch/utils/react_helpers'; - // The component. export default class ComposerOptionsDropdown extends React.PureComponent { @@ -50,7 +47,7 @@ export default class ComposerOptionsDropdown extends React.PureComponent { const { open } = this.state; if (this.props.isUserTouching && this.props.isUserTouching()) { - if (this.state.open) { + if (open) { this.props.onModalClose(); } else { const modal = this.handleMakeModal(); @@ -59,10 +56,10 @@ export default class ComposerOptionsDropdown extends React.PureComponent { } } } else { - if (this.state.open && this.activeElement) { + if (open && this.activeElement) { this.activeElement.focus({ preventScroll: true }); } - this.setState({ open: !this.state.open, openedViaKeyboard: type !== 'click' }); + this.setState({ open: !open, openedViaKeyboard: type !== 'click' }); } }; diff --git a/app/javascript/flavours/glitch/features/compose/components/dropdown_menu.jsx b/app/javascript/flavours/glitch/features/compose/components/dropdown_menu.jsx index 1ccccad31a..de50f566d9 100644 --- a/app/javascript/flavours/glitch/features/compose/components/dropdown_menu.jsx +++ b/app/javascript/flavours/glitch/features/compose/components/dropdown_menu.jsx @@ -1,7 +1,6 @@ // Package imports. import PropTypes from 'prop-types'; import React from 'react'; -import ImmutablePureComponent from 'react-immutable-pure-component'; import classNames from 'classnames'; // Components. @@ -9,7 +8,6 @@ import Icon from 'flavours/glitch/components/icon'; // Utils. import { withPassive } from 'flavours/glitch/utils/dom_helpers'; -import { assignHandlers } from 'flavours/glitch/utils/react_helpers'; // The component. export default class ComposerOptionsDropdownContent extends React.PureComponent { @@ -78,7 +76,8 @@ export default class ComposerOptionsDropdownContent extends React.PureComponent items, } = this.props; - const { name } = this.props.items[i]; + const { name } = items[i]; + e.preventDefault(); // Prevents change in focus on click if (closeOnChange) { onClose(); @@ -131,7 +130,7 @@ export default class ComposerOptionsDropdownContent extends React.PureComponent if (element) { element.focus(); - this.handleChange(this.props.items[Number(element.getAttribute('data-index'))].name); + this.handleChange(items[Number(element.getAttribute('data-index'))].name); e.preventDefault(); e.stopPropagation(); } @@ -169,6 +168,7 @@ export default class ComposerOptionsDropdownContent extends React.PureComponent onClick={this.handleClick} onKeyDown={this.handleKeyDown} role='option' + aria-selected={active} tabIndex={0} key={name} data-index={i} @@ -183,8 +183,6 @@ export default class ComposerOptionsDropdownContent extends React.PureComponent render () { const { items, - onChange, - onClose, style, } = this.props; diff --git a/app/javascript/flavours/glitch/features/compose/components/poll_form.jsx b/app/javascript/flavours/glitch/features/compose/components/poll_form.jsx index cbd53c4d5e..694ee3a04f 100644 --- a/app/javascript/flavours/glitch/features/compose/components/poll_form.jsx +++ b/app/javascript/flavours/glitch/features/compose/components/poll_form.jsx @@ -145,6 +145,7 @@ class PollForm extends ImmutablePureComponent {
+ {/* eslint-disable-next-line jsx-a11y/no-onchange */} 0 && options.map((opt) => { let optionId = `${id}--${opt.value}`; return ( -