Skip to content

Commit

Permalink
Fixed remote file input (#570)
Browse files Browse the repository at this point in the history
  • Loading branch information
roll authored Sep 27, 2024
1 parent 899de5a commit 0f62d89
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
8 changes: 8 additions & 0 deletions client/components/Application/Content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export default function Content() {

function FileContent() {
const record = store.useStore((state) => state.record)
const dialog = store.useStore((state) => state.dialog)
if (!record) return null

const Controller = CONTROLLERS[record.type] || File
Expand All @@ -50,6 +51,13 @@ function FileContent() {
mouseEvent="onMouseDown"
touchEvent="onTouchStart"
onClickAway={(event) => {
// Generally speaking, it will be better to migrate away
// from using ClickAwayListener for this purpose. See this weird bug:
// https://github.com/okfn/opendataeditor/issues/559
// As alternative, store's actions just check for unsaved changes
// when the user does something that requires it.
if (dialog) return

event.preventDefault()
store.onFileLeave()
}}
Expand Down
3 changes: 1 addition & 2 deletions client/store/actions/file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -290,10 +290,9 @@ export async function onFileDeleted(paths: string[]) {
}

export function onFileLeave() {
const { dialog } = store.getState()
const isUpdated = getIsFileOrResourceUpdated(store.getState())

if (isUpdated && !dialog) {
if (isUpdated) {
openDialog('unsavedChanges')
}
}
Expand Down

0 comments on commit 0f62d89

Please sign in to comment.