Skip to content

Commit

Permalink
Merge pull request #110 from nih-sparc/fix-sparc-tooltip-bug
Browse files Browse the repository at this point in the history
fixed sparc tooltip bug
  • Loading branch information
egauzens authored Jun 7, 2022
2 parents 04c77c2 + 10ccb1c commit 92ac874
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
7 changes: 6 additions & 1 deletion src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@
</div>
<sparc-tooltip placement="top-center" is-repeating-item-content>
<div slot="data">Only show this tooltip if content is cutoff</div>
<p slot="item">Only show tooltip when this has ellipsis</p>
<div class="tooltip-item" slot="item">Only show tooltip when this has ellipsis</div>
</sparc-tooltip>
<el-row type="flex" justify="center">
<el-select
Expand Down Expand Up @@ -961,4 +961,9 @@ export default {
.metadata-title {
font-weight: 500;
}
.tooltip-item {
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
}
</style>
9 changes: 6 additions & 3 deletions src/components/SparcTooltip/src/SparcTooltip.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
</template>

<script>
import { pathOr, isEmpty } from 'ramda'
const PLACEMENTS = Object.freeze({
'top-left': 'bottom-start',
'top-center': 'bottom',
Expand Down Expand Up @@ -79,15 +82,15 @@ export default {
onEnterTooltip(e) {
// Hide the tooltip if it is simply repeating the items content and the items content is not cut off
if (!this.isRepeatingItemContent) { return }
const target = e.target
this.hidden = target.scrollWidth <= target.offsetWidth
const targetElement = pathOr(null, ['target', 'firstChild'], e)
if (isEmpty(targetElement)) { return }
this.hidden = targetElement.scrollWidth <= targetElement.offsetWidth
}
}
}
</script>
<style lang="scss" scoped>
.tooltip-item {
display: flex;
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
Expand Down

0 comments on commit 92ac874

Please sign in to comment.