Skip to content

Commit

Permalink
fix: editor not getting focus when clicking inside the welcome screen…
Browse files Browse the repository at this point in the history
… of table mode
  • Loading branch information
josdejong committed Mar 13, 2024
1 parent 7123249 commit 919a31e
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/lib/components/controls/SearchBox.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,6 @@
// we pass searchText and json as argument to trigger search when these variables change,
// via various listeners like applyChangedSearchText
async function applySearch(showSearch: boolean, text: string, json: unknown) {
debug('applySearch', { showSearch, text })
if (!showSearch) {
if (searchResult) {
searchResult = undefined
Expand All @@ -238,6 +237,8 @@
return
}
debug('applySearch', { showSearch, text })
if (text === '') {
debug('clearing search result')
Expand Down
14 changes: 13 additions & 1 deletion src/lib/components/modes/tablemode/TableMode.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2026,7 +2026,19 @@
/>
<JSONPreview {text} {json} {indentation} {parser} />
{:else}
<TableModeWelcome {text} {json} {readOnly} {parser} {openJSONEditorModal} {onChangeMode} />
<TableModeWelcome
{text}
{json}
{readOnly}
{parser}
{openJSONEditorModal}
{onChangeMode}
onClick={() => {
// FIXME: this is a workaround for the editor not putting the focus on refHiddenInput
// when clicking in the welcome screen so you cannot paste a document from clipboard.
focus()
}}
/>
{/if}
{:else}
<div class="jse-contents jse-contents-loading">
Expand Down
3 changes: 2 additions & 1 deletion src/lib/components/modes/tablemode/TableModeWelcome.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
export let parser: JSONParser
export let openJSONEditorModal: (path: JSONPath) => void
export let onChangeMode: OnChangeMode
export let onClick: () => void
$: action = readOnly ? 'View' : 'Edit'
Expand Down Expand Up @@ -43,7 +44,7 @@
}
</script>

<div class="jse-table-mode-welcome">
<div class="jse-table-mode-welcome" on:click={() => onClick()} role="none">
<div class="jse-space jse-before" />

<div class="jse-nested-arrays">
Expand Down
3 changes: 1 addition & 2 deletions src/lib/components/modes/treemode/TreeMode.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2040,8 +2040,7 @@
}}
onClick={() => {
// FIXME: this is a workaround for the editor not putting the focus on refHiddenInput
// when clicking in the welcome screen (only occurs in 'tree' mode,
// so you cannot paste a document from clipboard.
// when clicking in the welcome screen so you cannot paste a document from clipboard.
focus()
}}
/>
Expand Down

0 comments on commit 919a31e

Please sign in to comment.