mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-08-20 08:01:35 +00:00
fix(frontend): fix first row selection (#1125)
* fix(frontend): fix first row selection * fix(frontend): fix order of conditions
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
<script lang="ts">
|
||||
import { getContext } from 'svelte'
|
||||
import { getContext, onMount } from 'svelte'
|
||||
import type { Output } from '../../rx'
|
||||
import type { AppEditorContext, BaseAppComponent, ButtonComponent } from '../../types'
|
||||
import InputValue from '../helpers/InputValue.svelte'
|
||||
@@ -31,7 +31,7 @@
|
||||
|
||||
$: setSearch(searchValue)
|
||||
|
||||
function setSearch(srch) {
|
||||
function setSearch(srch: string) {
|
||||
outputs?.search?.set(srch)
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@
|
||||
const { worldStore, staticOutputs: staticOutputsStore } =
|
||||
getContext<AppEditorContext>('AppEditorContext')
|
||||
|
||||
let selectedRowIndex = 0
|
||||
let selectedRowIndex = -1
|
||||
|
||||
function toggleRow(row: Record<string, any>, rowIndex: number) {
|
||||
if (selectedRowIndex !== rowIndex) {
|
||||
@@ -55,6 +55,18 @@
|
||||
}
|
||||
}
|
||||
|
||||
let mounted = false
|
||||
onMount(() => {
|
||||
mounted = true
|
||||
})
|
||||
|
||||
$: selectedRowIndex === -1 &&
|
||||
Array.isArray(result) &&
|
||||
result.length > 0 &&
|
||||
// We need to wait until the component is mounted so the world is created
|
||||
mounted &&
|
||||
toggleRow({ original: result[0] }, 0)
|
||||
|
||||
function setOptions(filteredResult: Array<Record<string, any>>) {
|
||||
if (!Array.isArray(result)) {
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user