Skip to content

Commit

Permalink
Prevent dataset edit modal closing on click-away in edit mode (#20278)
Browse files Browse the repository at this point in the history
  • Loading branch information
reesercollins authored Jun 15, 2022
1 parent 1882c6d commit 498987a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 }) {
Expand Down Expand Up @@ -629,6 +631,7 @@ class DatasourceEditor extends React.PureComponent {
}

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();

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

interface StyledModalProps {
Expand Down

0 comments on commit 498987a

Please sign in to comment.