Skip to content

Commit 3e34e8d

Browse files
committedOct 2, 2023
fix: regression since v0.18.17 not allowing to put the cursor halfway the value when editing a value
1 parent 43bc23f commit 3e34e8d

File tree

3 files changed

+16
-13
lines changed

3 files changed

+16
-13
lines changed
 

‎src/lib/components/modes/tablemode/TableMode.svelte

+1-4
Original file line numberDiff line numberDiff line change
@@ -730,10 +730,7 @@
730730
setTimeout(() => {
731731
setTimeout(() => {
732732
// for example when clicking on the empty area in the main menu
733-
if (
734-
(!hasFocus && !isChildOfNodeName(event.target, 'BUTTON')) ||
735-
event.target.nodeName === 'DIV'
736-
) {
733+
if (!hasFocus && !isChildOfNodeName(event.target, 'BUTTON')) {
737734
focus()
738735
}
739736
})

‎src/lib/components/modes/treemode/TreeMode.svelte

+7-4
Original file line numberDiff line numberDiff line change
@@ -1820,10 +1820,7 @@
18201820
// TODO: ugly to have two setTimeout here. Without it, hiddenInput will blur
18211821
setTimeout(() => {
18221822
setTimeout(() => {
1823-
if (
1824-
(!hasFocus && !isChildOfNodeName(event.target, 'BUTTON')) ||
1825-
event.target.nodeName === 'DIV'
1826-
) {
1823+
if (!hasFocus && !isChildOfNodeName(event.target, 'BUTTON')) {
18271824
// for example when clicking on the empty area in the main menu
18281825
focus()
18291826
@@ -2164,6 +2161,12 @@
21642161
focus()
21652162
handleInsertCharacter('[')
21662163
}}
2164+
onClick={() => {
2165+
// FIXME: this is a workaround for the editor not putting the focus on refHiddenInput
2166+
// when clicking in the welcome screen (only occurs in 'tree' mode,
2167+
// so you cannot paste a document from clipboard.
2168+
focus()
2169+
}}
21672170
/>
21682171
{:else}
21692172
<Message

‎src/lib/components/modes/treemode/Welcome.svelte

+8-5
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,24 @@
44
export let readOnly: boolean
55
export let onCreateArray: () => void
66
export let onCreateObject: () => void
7+
export let onClick: () => void
78
</script>
89

9-
<div class="jse-welcome">
10+
<div class="jse-welcome" on:click={() => onClick()} role="none">
1011
<div class="jse-space jse-before" />
1112
<div class="jse-contents">
1213
<div class="jse-welcome-title">Empty document</div>
1314
{#if !readOnly}
1415
<div class="jse-welcome-info">
1516
You can paste clipboard data using <b>Ctrl+V</b>, or use the following options:
1617
</div>
17-
<button title={"Create an empty JSON object (press '{')"} on:click={() => onCreateObject()}
18-
>Create object</button
18+
<button
19+
title={"Create an empty JSON object (press '{')"}
20+
on:click|stopPropagation={() => onCreateObject()}>Create object</button
1921
>
20-
<button title={"Create an empty JSON array (press '[')"} on:click={() => onCreateArray()}
21-
>Create array</button
22+
<button
23+
title={"Create an empty JSON array (press '[')"}
24+
on:click|stopPropagation={() => onCreateArray()}>Create array</button
2225
>
2326
{/if}
2427
</div>

0 commit comments

Comments
 (0)
Please sign in to comment.