Skip to content

fix safari dropdown not getting closed when click outside #2619

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions client/modules/IDE/components/AssetList.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import PropTypes from 'prop-types';
import React from 'react';
import OutsideClickHandler from 'react-outside-click-handler';
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
import { Link } from 'react-router-dom';
Expand All @@ -11,6 +12,8 @@ import Loader from '../../App/components/loader';
import * as AssetActions from '../actions/assets';
import DownFilledTriangleIcon from '../../../images/down-filled-triangle.svg';

const isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);

class AssetListRowBase extends React.Component {
constructor(props) {
super(props);
Expand Down Expand Up @@ -104,6 +107,15 @@ class AssetListRowBase extends React.Component {
onFocus={this.onFocusComponent}
>
{t('AssetList.Delete')}
{isSafari && (
<OutsideClickHandler
onOutsideClick={() => {
this.setState({
optionsOpen: false
});
}}
/>
)}
</button>
</li>
<li>
Expand Down
12 changes: 12 additions & 0 deletions client/modules/IDE/components/CollectionList/CollectionListRow.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import PropTypes from 'prop-types';
import React from 'react';
import OutsideClickHandler from 'react-outside-click-handler';
import { connect } from 'react-redux';
import { Link } from 'react-router-dom';
import { bindActionCreators } from 'redux';
Expand All @@ -16,6 +17,8 @@ import MoreIconSvg from '../../../../images/more.svg';
const formatDateCell = (date, mobile = false) =>
dates.format(date, { showTime: !mobile });

const isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);

class CollectionListRowBase extends React.Component {
static projectInCollection(project, collection) {
return (
Expand Down Expand Up @@ -166,6 +169,15 @@ class CollectionListRowBase extends React.Component {
onFocus={this.onFocusComponent}
>
{this.props.t('CollectionListRow.AddSketch')}
{isSafari && (
<OutsideClickHandler
onOutsideClick={() => {
this.setState({
optionsOpen: false
});
}}
/>
)}
</button>
</li>
{userIsOwner && (
Expand Down
8 changes: 8 additions & 0 deletions client/modules/IDE/components/Sidebar.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React, { useRef, useState } from 'react';
import OutsideClickHandler from 'react-outside-click-handler';
import classNames from 'classnames';
import { useTranslation } from 'react-i18next';
import { useDispatch, useSelector } from 'react-redux';
Expand Down Expand Up @@ -112,6 +113,13 @@ export default function SideBar() {
onFocus={onFocusComponent}
>
{t('Sidebar.AddFolder')}
{projectOptionsVisible && (
<OutsideClickHandler
onOutsideClick={() => {
dispatch(closeProjectOptions());
}}
/>
)}
</button>
</li>
<li>
Expand Down
12 changes: 12 additions & 0 deletions client/modules/IDE/components/SketchList.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import PropTypes from 'prop-types';
import React from 'react';
import OutsideClickHandler from 'react-outside-click-handler';
import { Helmet } from 'react-helmet';
import { withTranslation } from 'react-i18next';
import { connect } from 'react-redux';
Expand Down Expand Up @@ -27,6 +28,8 @@ import MoreIconSvg from '../../../images/more.svg';

const ROOT_URL = getConfig('API_URL');

const isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);

const formatDateCell = (date, mobile = false) =>
dates.format(date, { showTime: !mobile });

Expand Down Expand Up @@ -227,6 +230,15 @@ class SketchListRowBase extends React.Component {
onFocus={this.onFocusComponent}
>
{this.props.t('SketchList.DropdownDownload')}
{isSafari && (
<OutsideClickHandler
onOutsideClick={() => {
this.setState({
optionsOpen: false
});
}}
/>
)}
</button>
</li>
{this.props.user.authenticated && (
Expand Down
Loading