Skip to content
代码片段 群组 项目
提交 fb10dba3 编辑于 作者: Sarah Yasonik's avatar Sarah Yasonik 提交者: Alexander Turinske
浏览文件

Stop flashing issue description on details toggle

Issue description flashes an animation for task completion
to indicate a change. This is unneeded for <details> html
tags opening and closing, because the issue description
did not in fact change. The commit removes the animation
for that scenario.

Changelog: changed
上级 1cb9b9a8
No related branches found
No related tags found
无相关合并请求
...@@ -132,7 +132,10 @@ export default { ...@@ -132,7 +132,10 @@ export default {
}, },
watch: { watch: {
descriptionHtml(newDescription, oldDescription) { descriptionHtml(newDescription, oldDescription) {
if (!this.initialUpdate && newDescription !== oldDescription) { if (
!this.initialUpdate &&
this.stripClientState(newDescription) !== this.stripClientState(oldDescription)
) {
this.animateChange(); this.animateChange();
} else { } else {
this.initialUpdate = false; this.initialUpdate = false;
...@@ -321,6 +324,9 @@ export default { ...@@ -321,6 +324,9 @@ export default {
listItem.append(element); listItem.append(element);
} }
}, },
stripClientState(description) {
return description.replaceAll('<details open="true">', '<details>');
},
async createTask({ taskTitle, taskDescription, oldDescription }) { async createTask({ taskTitle, taskDescription, oldDescription }) {
try { try {
const { title, description } = extractTaskTitleAndDescription(taskTitle, taskDescription); const { title, description } = extractTaskTitleAndDescription(taskTitle, taskDescription);
......
...@@ -19,7 +19,11 @@ import { ...@@ -19,7 +19,11 @@ import {
getIssueDetailsResponse, getIssueDetailsResponse,
projectWorkItemTypesQueryResponse, projectWorkItemTypesQueryResponse,
} from 'jest/work_items/mock_data'; } from 'jest/work_items/mock_data';
import { descriptionProps as initialProps, descriptionHtmlWithList } from '../mock_data/mock_data'; import {
descriptionProps as initialProps,
descriptionHtmlWithList,
descriptionHtmlWithDetailsTag,
} from '../mock_data/mock_data';
jest.mock('~/alert'); jest.mock('~/alert');
jest.mock('~/task_list'); jest.mock('~/task_list');
...@@ -111,6 +115,19 @@ describe('Description component', () => { ...@@ -111,6 +115,19 @@ describe('Description component', () => {
expect(findGfmContent().classes()).toContain('issue-realtime-trigger-pulse'); expect(findGfmContent().classes()).toContain('issue-realtime-trigger-pulse');
}); });
it('doesnt animate expand/collapse of details elements', async () => {
createComponent();
await wrapper.setProps({ descriptionHtml: descriptionHtmlWithDetailsTag.collapsed });
expect(findGfmContent().classes()).not.toContain('issue-realtime-pre-pulse');
await wrapper.setProps({ descriptionHtml: descriptionHtmlWithDetailsTag.expanded });
expect(findGfmContent().classes()).not.toContain('issue-realtime-pre-pulse');
await wrapper.setProps({ descriptionHtml: descriptionHtmlWithDetailsTag.collapsed });
expect(findGfmContent().classes()).not.toContain('issue-realtime-pre-pulse');
});
it('applies syntax highlighting and math when description changed', async () => { it('applies syntax highlighting and math when description changed', async () => {
createComponent(); createComponent();
......
...@@ -79,3 +79,16 @@ export const descriptionHtmlWithList = ` ...@@ -79,3 +79,16 @@ export const descriptionHtmlWithList = `
<li data-sourcepos="3:1-3:8">todo 3</li> <li data-sourcepos="3:1-3:8">todo 3</li>
</ul> </ul>
`; `;
export const descriptionHtmlWithDetailsTag = {
expanded: `
<details open="true">
<summary>Section 1</summary>
<p>Data</p>
</details>'`,
collapsed: `
<details>
<summary>Section 1</summary>
<p>Data</p>
</details>'`,
};
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册