Commit 81cf9db1 authored by Vitaly Slobodin's avatar Vitaly Slobodin Committed by Andrew Fontaine

Do not render empty title in HelpPopover

Do not render title in HelpPopover if it was not provided.

(Also use `GlSafeHtmlDirective` instead of `v-html`).
parent 8de1bc8a
<script> <script>
import { GlButton, GlPopover } from '@gitlab/ui'; import { GlButton, GlPopover, GlSafeHtmlDirective } from '@gitlab/ui';
/** /**
* Render a button with a question mark icon * Render a button with a question mark icon
...@@ -11,6 +11,9 @@ export default { ...@@ -11,6 +11,9 @@ export default {
GlButton, GlButton,
GlPopover, GlPopover,
}, },
directives: {
SafeHtml: GlSafeHtmlDirective,
},
props: { props: {
options: { options: {
type: Object, type: Object,
...@@ -24,13 +27,11 @@ export default { ...@@ -24,13 +27,11 @@ export default {
<span> <span>
<gl-button ref="popoverTrigger" variant="link" icon="question" tabindex="0" /> <gl-button ref="popoverTrigger" variant="link" icon="question" tabindex="0" />
<gl-popover triggers="hover focus" :target="() => $refs.popoverTrigger.$el" v-bind="options"> <gl-popover triggers="hover focus" :target="() => $refs.popoverTrigger.$el" v-bind="options">
<template #title> <template v-if="options.title" #title>
<!-- eslint-disable-next-line vue/no-v-html --> <span v-safe-html="options.title"></span>
<span v-html="options.title"></span>
</template> </template>
<template #default> <template #default>
<!-- eslint-disable-next-line vue/no-v-html --> <div v-safe-html="options.content"></div>
<div v-html="options.content"></div>
</template> </template>
</gl-popover> </gl-popover>
</span> </span>
......
---
title: Do not render empty title in HelpPopover
merge_request: 57025
author:
type: fixed
...@@ -27,7 +27,6 @@ describe('HelpPopover', () => { ...@@ -27,7 +27,6 @@ describe('HelpPopover', () => {
afterEach(() => { afterEach(() => {
wrapper.destroy(); wrapper.destroy();
wrapper = null;
}); });
it('renders a link button with an icon question', () => { it('renders a link button with an icon question', () => {
...@@ -54,6 +53,14 @@ describe('HelpPopover', () => { ...@@ -54,6 +53,14 @@ describe('HelpPopover', () => {
expect(findPopover().find('b').exists()).toBe(true); expect(findPopover().find('b').exists()).toBe(true);
}); });
describe('without title', () => {
it('does not render title', () => {
buildWrapper({ title: null });
expect(findPopover().find('span').exists()).toBe(false);
});
});
it('binds other popover options to the popover instance', () => { it('binds other popover options to the popover instance', () => {
const placement = 'bottom'; const placement = 'bottom';
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment