diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-13 21:08:59 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-13 21:08:59 +0000 |
commit | d466ee5042520ad078fe050cb078d81dc2ebe196 (patch) | |
tree | 5648eb1aee8aeff5b5c5ff4669a184fd7676f778 /app/assets/javascripts/vue_shared/components/tooltip_on_truncate.vue | |
parent | 6a9d7c009e4e5975a89bcc3e458da4b3ec484bd1 (diff) | |
download | gitlab-ce-d466ee5042520ad078fe050cb078d81dc2ebe196.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/assets/javascripts/vue_shared/components/tooltip_on_truncate.vue')
-rw-r--r-- | app/assets/javascripts/vue_shared/components/tooltip_on_truncate.vue | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/app/assets/javascripts/vue_shared/components/tooltip_on_truncate.vue b/app/assets/javascripts/vue_shared/components/tooltip_on_truncate.vue index 69eb791d195..4ea3d162da2 100644 --- a/app/assets/javascripts/vue_shared/components/tooltip_on_truncate.vue +++ b/app/assets/javascripts/vue_shared/components/tooltip_on_truncate.vue @@ -1,5 +1,5 @@ <script> -import _ from 'underscore'; +import { isFunction } from 'lodash'; import tooltip from '../directives/tooltip'; export default { @@ -28,16 +28,18 @@ export default { showTooltip: false, }; }, + watch: { + title() { + // Wait on $nextTick in case of slot width changes + this.$nextTick(this.updateTooltip); + }, + }, mounted() { - const target = this.selectTarget(); - - if (target && target.scrollWidth > target.offsetWidth) { - this.showTooltip = true; - } + this.updateTooltip(); }, methods: { selectTarget() { - if (_.isFunction(this.truncateTarget)) { + if (isFunction(this.truncateTarget)) { return this.truncateTarget(this.$el); } else if (this.truncateTarget === 'child') { return this.$el.childNodes[0]; @@ -45,6 +47,10 @@ export default { return this.$el; }, + updateTooltip() { + const target = this.selectTarget(); + this.showTooltip = Boolean(target && target.scrollWidth > target.offsetWidth); + }, }, }; </script> |