Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CT-1930 show tooltip on hover select option #95

Merged
Merged
Show file tree
Hide file tree
Changes from all 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
9 changes: 9 additions & 0 deletions src/components/Select/Select.vue
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,11 @@
components: {
TextField, Popper, SelectMenu, Tag, Icons
},
provide() {
return {
$showOptionTooltip: this.showOptionTooltip
};
},
props: {
value: {
type: [String, Number, Object, Array],
Expand Down Expand Up @@ -238,6 +243,10 @@
dropdownWidth: {
type: Number,
default: undefined
},
showOptionTooltip: {
type: Boolean,
default: false
}
},
data() {
Expand Down
39 changes: 38 additions & 1 deletion src/components/Select/SelectOption.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,29 @@
<template>
<div
<Tooltip
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not 100% happy with this, there is some code duplication, but i couldn't came up with better solution. I've consulted this with Mateusz Zieliński and he also said in that case duplicating some code would be neccesary. If you have any suggestions to make it better, please write that down

v-if="this.$showOptionTooltip"
class="tooltip-wrapper"
placement="top"
:label="option.value"
>
<div
ref="option"
:selected="isSelected"
class="select-option"
:current="current"
@click.stop="onOptionSelected"
@mouseover="onMouseOver"
>
<slot
name="option"
:option="option.value"
:is-current="current"
>
{{ option.label }}
</slot>
</div>
</Tooltip>
<div
v-else
ref="option"
:selected="isSelected"
class="select-option"
Expand All @@ -18,8 +42,17 @@
</template>

<script>
import Tooltip from '../Tooltip/Tooltip';

export default {
name: 'SelectOption',
components: { Tooltip },
inject: {
$showOptionTooltip: {
from: '$showOptionTooltip',
default: undefined
}
},
props: {
option: {
type: Object,
Expand Down Expand Up @@ -74,6 +107,10 @@
</script>

<style scoped>

.tooltip-wrapper {
width: 100%;
}
.select-option {
cursor: pointer;
display: block;
Expand Down
Loading