Skip to content
This repository has been archived by the owner on Mar 23, 2023. It is now read-only.

fix: InputSelect dropdowns #1174

Merged
merged 3 commits into from
Apr 10, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 30 additions & 42 deletions src/renderer/components/Input/InputSelect.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,45 +7,43 @@
class="InputSelect"
@select="onDropdownSelect"
>
<div
<template
v-if="hasItemSlot"
slot="item"
slot-scope="itemScope"
v-slot:item="itemScope"
>
<slot
name="input-item"
v-bind="itemScope"
/>
</div>

<InputField
slot="handler"
slot-scope="handlerScope"
:name="name"
:label="inputLabel"
:value="optionText"
:is-dirty="isDirty"
:is-disabled="isDisabled"
:is-focused="isFocused"
:is-invalid="isInvalid"
>
<MenuDropdownHandler
slot-scope="{ inputClass }"
:value="handlerScope.value"
:item="handlerScope.item"
:class="inputClass"
:placeholder="label"
:on-blur="onBlur"
class="InputSelect__input"
@click="onHandlerClick"
</template>

<template v-slot:handler="handlerScope">
<InputField
:name="name"
:label="inputLabel"
:value="optionText"
:is-dirty="isDirty"
:is-disabled="isDisabled"
:is-focused="isFocused"
:is-invalid="isInvalid"
>
<slot
v-if="hasHandlerSlot"
name="input-handler"
v-bind="handlerScope"
/>
</MenuDropdownHandler>
</InputField>
<MenuDropdownHandler
slot-scope="{ inputClass }"
:value="handlerScope.value"
:item="handlerScope.item"
:class="inputClass"
:placeholder="label"
class="InputSelect__input"
@click="onHandlerClick"
>
<slot
v-if="hasHandlerSlot"
name="input-handler"
v-bind="handlerScope"
/>
</MenuDropdownHandler>
</InputField>
</template>
</MenuDropdown>
</template>

Expand Down Expand Up @@ -158,16 +156,6 @@ export default {
this.optionValue = selectedValue

this.emitInput()
},

onBlur (ev) {
this.$nextTick(() => {
if (Object.values(document.activeElement.classList).includes('MenuDropdownItem__button')) {
ev.preventDefault()
} else {
this.$refs.dropdown.close()
}
})
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/renderer/components/Menu/MenuDropdown/MenuDropdown.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
v-if="!hasDefaultSlot"
:disabled="isDisabled"
class="appearance-none text-inherit w-full"
@click.stop="buttonClick"
@click.stop="handlerWrapperClick"
>
<slot
:active-value="activeValue"
Expand Down Expand Up @@ -177,7 +177,7 @@ export default {
this.$emit('select', item)
},

buttonClick () {
handlerWrapperClick () {
this.toggle()
this.$emit('click')
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
value ? '' : 'text-theme-page-text-light hover:text-theme-page-text',
'MenuDropdownHandler cursor-pointer transition flex justify-between items-center text-inherit']"
@click="emitClick"
@blur="onBlur"
>
<span>
<slot>
Expand Down Expand Up @@ -70,12 +69,6 @@ export default {
type: String,
required: false,
default: ''
},

onBlur: {
type: Function,
required: false,
default: () => {}
}
},

Expand Down