Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prevent dataset edit modal closing on click-away in edit mode
Browse files Browse the repository at this point in the history
reesercollins committed Jun 6, 2022

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 77e326f commit 5d0d5c6
Showing 3 changed files with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -518,10 +518,12 @@ const propTypes = {
onChange: PropTypes.func,
addSuccessToast: PropTypes.func.isRequired,
addDangerToast: PropTypes.func.isRequired,
setIsEditing: PropTypes.func,
};

const defaultProps = {
onChange: () => {},
setIsEditing: () => {},
};

function OwnersSelector({ datasource, onChange }) {
@@ -629,6 +631,7 @@ class DatasourceEditor extends React.PureComponent {
}

onChangeEditMode() {
this.props.setIsEditing(!this.state.isEditMode);
this.setState(prevState => ({ isEditMode: !prevState.isEditMode }));
}

Original file line number Diff line number Diff line change
@@ -84,6 +84,7 @@ const DatasourceModal: FunctionComponent<DatasourceModalProps> = ({
const [currentDatasource, setCurrentDatasource] = useState(datasource);
const [errors, setErrors] = useState<any[]>([]);
const [isSaving, setIsSaving] = useState(false);
const [isEditing, setIsEditing] = useState<boolean>(false);
const dialog = useRef<any>(null);
const [modal, contextHolder] = Modal.useModal();

@@ -193,6 +194,7 @@ const DatasourceModal: FunctionComponent<DatasourceModalProps> = ({
<strong>{currentDatasource.table_name}</strong>
</span>
}
maskClosable={!isEditing}
footer={
<>
{showLegacyDatasourceEditor && (
@@ -246,6 +248,7 @@ const DatasourceModal: FunctionComponent<DatasourceModalProps> = ({
height={500}
datasource={currentDatasource}
onChange={onDatasourceChange}
setIsEditing={setIsEditing}
/>
{contextHolder}
</StyledDatasourceModal>
1 change: 1 addition & 0 deletions superset-frontend/src/components/Modal/Modal.tsx
Original file line number Diff line number Diff line change
@@ -56,6 +56,7 @@ export interface ModalProps {
draggable?: boolean;
draggableConfig?: DraggableProps;
destroyOnClose?: boolean;
maskClosable?: boolean;
}

interface StyledModalProps {

0 comments on commit 5d0d5c6

Please sign in to comment.