Skip to content

Add new file/folder bugfix #1602

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

Merged
merged 3 commits into from
Sep 4, 2020
Merged
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
13 changes: 13 additions & 0 deletions client/modules/IDE/components/NewFileModal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,23 @@ class NewFileModal extends React.Component {
constructor(props) {
super(props);
this.focusOnModal = this.focusOnModal.bind(this);
this.handleOutsideClick = this.handleOutsideClick.bind(this);
}

componentDidMount() {
this.focusOnModal();
document.addEventListener('click', this.handleOutsideClick, false);
}

componentWillUnmount() {
document.removeEventListener('click', this.handleOutsideClick, false);
}

handleOutsideClick(e) {
// ignore clicks on the component itself
if (e.path.includes(this.modal)) return;

this.props.closeNewFileModal();
}

focusOnModal() {
Expand Down
17 changes: 17 additions & 0 deletions client/modules/IDE/components/NewFolderModal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,25 @@ import NewFolderForm from './NewFolderForm';
import ExitIcon from '../../../images/exit.svg';

class NewFolderModal extends React.Component {
constructor(props) {
super(props);
this.handleOutsideClick = this.handleOutsideClick.bind(this);
}

componentDidMount() {
this.newFolderModal.focus();
document.addEventListener('click', this.handleOutsideClick, false);
}

componentWillUnmount() {
document.removeEventListener('click', this.handleOutsideClick, false);
}

handleOutsideClick(e) {
// ignore clicks on the component itself
if (e.path.includes(this.newFolderModal)) return;

this.props.closeModal();
}

render() {
Expand Down
12 changes: 10 additions & 2 deletions client/modules/IDE/reducers/ide.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,11 @@ const ide = (state = initialState, action) => {
case ActionTypes.CONSOLE_EVENT:
return Object.assign({}, state, { consoleEvent: action.event });
case ActionTypes.SHOW_MODAL:
return Object.assign({}, state, { modalIsVisible: true, parentId: action.parentId });
return Object.assign({}, state, {
modalIsVisible: true,
parentId: action.parentId,
newFolderModalVisible: false
});
case ActionTypes.HIDE_MODAL:
return Object.assign({}, state, { modalIsVisible: false });
case ActionTypes.COLLAPSE_SIDEBAR:
Expand All @@ -62,7 +66,11 @@ const ide = (state = initialState, action) => {
case ActionTypes.CLOSE_PROJECT_OPTIONS:
return Object.assign({}, state, { projectOptionsVisible: false });
case ActionTypes.SHOW_NEW_FOLDER_MODAL:
return Object.assign({}, state, { newFolderModalVisible: true, parentId: action.parentId });
return Object.assign({}, state, {
newFolderModalVisible: true,
parentId: action.parentId,
modalIsVisible: false
});
case ActionTypes.CLOSE_NEW_FOLDER_MODAL:
return Object.assign({}, state, { newFolderModalVisible: false });
case ActionTypes.SHOW_SHARE_MODAL:
Expand Down