Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorianWendelborn committed Apr 24, 2022
1 parent 5ca866a commit b5c13cb
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -757,7 +757,7 @@ export default defineComponent({
isLoading: false,
isOptional: true,
},
component: 'KtFieldSingleSelectRemote',
component: 'KtFieldMultiSelectRemote',
decimalSeparator: Kotti.DecimalSeparator.DOT,
hasHelpTextSlot: false,
helpDescription: null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
<script lang="ts">
import { Yoco } from '@3yourmind/yoco'
import { computed, defineComponent, ref, watch } from '@vue/composition-api'
import Vue from 'vue'
import { z } from 'zod'
import { KtField } from '../../kotti-field'
Expand Down Expand Up @@ -191,6 +192,8 @@ export default defineComponent<
)
watch(isUserInteracting, (newValue) => {
console.info('isUserInteracting watcher')
if (props.isRemote) {
if (!newValue && props.query !== null) emit(UPDATE_QUERY, null)
} else localQuery.value = null
Expand All @@ -212,24 +215,36 @@ export default defineComponent<
o.label.toLowerCase().includes(localQuery.value.toLowerCase()),
),
),
handleInputBlur: (event: { relatedTarget: HTMLElement }) => {
const blurToElement = event.relatedTarget
if (
!isTippyOrInTippy(blurToElement, selectTippy.tippyContentRef.value)
) {
selectTippy.setIsDropdownOpen(false)
}
isInputFocused.value = false
handleInputBlur: async (event: { relatedTarget: HTMLElement }) => {
setTimeout(async () => {
console.info('handleInputBlur')
const blurToElement = event.relatedTarget
if (
!isTippyOrInTippy(blurToElement, selectTippy.tippyContentRef.value)
) {
await Vue.nextTick()
console.info('handleInputBlur close')
selectTippy.setIsDropdownOpen(false)
}
console.info('handleInputBlur remove isInputFocused')
isInputFocused.value = false
}, 500) // 100 isn’t enough...
},
handleInputClick: () => {
handleInputClick: async () => {
console.info('handleInputClick')
await Vue.nextTick()
console.info('handleInputClick open')
// always show the dropdown if the input was clicked
selectTippy.setIsDropdownOpen(true)
await Vue.nextTick()
console.info('handleInputClick focus')
inputRef.value?.focus()
setTimeout(() => {
// always show the dropdown if the input was clicked
selectTippy.setIsDropdownOpen(true)
}, 100)
},
handleInputFocus: () => {
console.info('handleInputFocus')
// always show the dropdown if the input was focused
selectTippy.setIsDropdownOpen(true)
isInputFocused.value = true
Expand Down Expand Up @@ -276,6 +291,8 @@ export default defineComponent<
: [field.currentValue as SingleValue]
}),
removeTag: (value: Shared.Option['value']) => {
console.info('removeTag', value)
if (!props.isMultiple)
throw new Error(
'GenericSelectField: Unexpected multi function on single select',
Expand Down
7 changes: 7 additions & 0 deletions packages/kotti-ui/source/kotti-field-select/todo.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,10 @@
- [ ] restore arrow-key navigation for options (isHovered)
- [ ] (optional) add slot support for options
- [ ] FIX: if field is multi and not empty and not interacting, hide input

## 2022-04-20

- 500ms delay on blur works but 100ms doesn’t...
- Consider <https://stackoverflow.com/a/38317768> and setting tippy to manual mode...
- Honestly, the most realistic and sustainable solution is to either move the search query inside the dropdown or to not show the tags
- Consider making `isInputVisible` delayed when closing so that it only updates after 500ms

0 comments on commit b5c13cb

Please sign in to comment.