Define current Select option from selected option and not default
This commit is contained in:
@@ -5,6 +5,7 @@
|
|||||||
value: string
|
value: string
|
||||||
name: string
|
name: string
|
||||||
default?: boolean
|
default?: boolean
|
||||||
|
selected?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
export let id: string
|
export let id: string
|
||||||
@@ -15,8 +16,9 @@
|
|||||||
const dispatch = createEventDispatcher()
|
const dispatch = createEventDispatcher()
|
||||||
const defaultOption = options.find(option => option.default)
|
const defaultOption = options.find(option => option.default)
|
||||||
const defaultOptionIndex = options.findIndex(option => option.default)
|
const defaultOptionIndex = options.findIndex(option => option.default)
|
||||||
|
const selectedOptionIndex = options.findIndex(option => option.selected)
|
||||||
|
|
||||||
let current: number = defaultOptionIndex
|
let current: number = selectedOptionIndex
|
||||||
let currentOptionEl: HTMLElement
|
let currentOptionEl: HTMLElement
|
||||||
$: currentOption = options[current]
|
$: currentOption = options[current]
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user