Commit bd6522df authored by Enrique Alcantara's avatar Enrique Alcantara Committed by Enrique Alcántara

Fix toolbar buttons in Markdown field

Fix a tabs migration bug where the toolbar
buttons in the Markdown field stop working
after switching between Edit and Preview
modes

Changelog: fixed
parent 632a455d
...@@ -171,8 +171,12 @@ export default { ...@@ -171,8 +171,12 @@ export default {
@click="previewMarkdownTab($event)" @click="previewMarkdownTab($event)"
/> />
<template v-if="!previewMarkdown" #tabs-end> <template #tabs-end>
<div class="md-header-toolbar gl-ml-auto gl-pb-3 gl-justify-content-center"> <div
data-testid="md-header-toolbar"
:class="{ 'gl-display-none': previewMarkdown }"
class="md-header-toolbar gl-ml-auto gl-pb-3 gl-justify-content-center"
>
<toolbar-button <toolbar-button
tag="**" tag="**"
:button-title=" :button-title="
......
...@@ -20,6 +20,7 @@ describe('Markdown field header component', () => { ...@@ -20,6 +20,7 @@ describe('Markdown field header component', () => {
const findWriteTab = () => wrapper.findByTestId('write-tab'); const findWriteTab = () => wrapper.findByTestId('write-tab');
const findPreviewTab = () => wrapper.findByTestId('preview-tab'); const findPreviewTab = () => wrapper.findByTestId('preview-tab');
const findToolbar = () => wrapper.findByTestId('md-header-toolbar');
const findToolbarButtons = () => wrapper.findAll(ToolbarButton); const findToolbarButtons = () => wrapper.findAll(ToolbarButton);
const findToolbarButtonByProp = (prop, value) => const findToolbarButtonByProp = (prop, value) =>
findToolbarButtons() findToolbarButtons()
...@@ -90,6 +91,12 @@ describe('Markdown field header component', () => { ...@@ -90,6 +91,12 @@ describe('Markdown field header component', () => {
expect(findPreviewTab().attributes('active')).toBe('true'); expect(findPreviewTab().attributes('active')).toBe('true');
}); });
it('hides toolbar in preview mode', () => {
createWrapper({ previewMarkdown: true });
expect(findToolbar().classes().includes('gl-display-none')).toBe(true);
});
it('emits toggle markdown event when clicking preview tab', async () => { it('emits toggle markdown event when clicking preview tab', async () => {
const eventData = { target: {} }; const eventData = { target: {} };
findPreviewTab().vm.$emit('click', eventData); findPreviewTab().vm.$emit('click', eventData);
......
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