diff --git a/src/lib/components/modals/JSONEditorModal.svelte b/src/lib/components/modals/JSONEditorModal.svelte index afccdeee..35f594d4 100644 --- a/src/lib/components/modals/JSONEditorModal.svelte +++ b/src/lib/components/modals/JSONEditorModal.svelte @@ -30,10 +30,9 @@ import Icon from 'svelte-awesome' import { faCaretLeft } from '@fortawesome/free-solid-svg-icons' import memoizeOne from 'memoize-one' - import { onEscape } from '$lib/actions/onEscape.js' import { getFocusPath, isJSONSelection } from '$lib/logic/selection.js' import Modal from './Modal.svelte' - import AbsolutePopup from '$lib/components/modals/popup/AbsolutePopup.svelte' + import AbsolutePopup from './popup/AbsolutePopup.svelte' const debug = createDebug('jsoneditor:JSONEditorModal') @@ -74,6 +73,7 @@ } let refEditor: JSONEditorRoot + let refApply: HTMLButtonElement let fullscreen: boolean const rootState: ModalState = { @@ -149,7 +149,10 @@ function handleClose() { debug('handleClose') - if (stack.length > 1) { + if (fullscreen) { + // exit fullscreen + fullscreen = false + } else if (stack.length > 1) { // remove the last item from the stack stack = initial(stack) tick().then(scrollToSelection) @@ -162,14 +165,6 @@ } } - function handleEscape() { - if (fullscreen) { - fullscreen = false - } else { - handleClose() - } - } - function handleChange(updatedContent: Content) { debug('handleChange', updatedContent) @@ -218,6 +213,8 @@ relativePath: path } stack = [...stack, nestedModalState] + + refApply.focus() } function focus(element: HTMLElement) { @@ -225,8 +222,8 @@ } - -
+ +
{/if} {#if !readOnly} - {:else} - {/if} diff --git a/src/lib/components/modals/Modal.svelte b/src/lib/components/modals/Modal.svelte index f725007b..8bad845c 100644 --- a/src/lib/components/modals/Modal.svelte +++ b/src/lib/components/modals/Modal.svelte @@ -12,10 +12,6 @@ onMount(() => dialog.showModal()) onDestroy(() => dialog.close()) - function handleEscape() { - onClose() - } - function close() { onClose() } @@ -26,11 +22,11 @@ bind:this={dialog} on:close={close} on:click|self={close} + use:onEscape={close} class={className} class:jse-fullscreen={fullscreen} > - -
+
@@ -40,11 +36,13 @@ dialog { border-radius: $border-radius; + font-size: $padding; // for some reason that I don't understand, the font-size of the dialog is used as margin around the dialog border: none; padding: 0; display: flex; min-width: 0; overflow: visible; + transition: width 0.1s ease-in-out, height 0.1s ease-in-out; &.jse-sort-modal { width: 400px; @@ -62,7 +60,7 @@ &.jse-transform-modal { width: 1200px; - height: 1200px; + height: 800px; } &.jse-fullscreen {