This is an automated email from the ASF dual-hosted git repository.
lizhimins pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/rocketmq-dashboard.git
The following commit(s) were added to refs/heads/master by this push:
new 2b245ad89 fix(topic): make property removal keyboard accessible (#7385)
2b245ad89 is described below
commit 2b245ad8960b5b7b248776939e84aaba9ae3834b
Author: zmuxuny <[email protected]>
AuthorDate: Fri Nov 27 12:32:51 2026 +0800
fix(topic): make property removal keyboard accessible (#7385)
---
web/src/i18n/translations.ts | 1 +
.../pages/instance/__tests__/TopicPage.test.tsx | 80 ++++++++++++++++++++++
web/src/pages/instance/topic.tsx | 9 ++-
3 files changed, 88 insertions(+), 2 deletions(-)
diff --git a/web/src/i18n/translations.ts b/web/src/i18n/translations.ts
index b78bec39f..1b0783674 100644
--- a/web/src/i18n/translations.ts
+++ b/web/src/i18n/translations.ts
@@ -3248,6 +3248,7 @@ const translations: Record<string, Record<Lang, string>>
= {
'topic.propName': { zh: '属性名', en: 'Property Name' },
'topic.propValue': { zh: '属性值', en: 'Property Value' },
'topic.addProp': { zh: '添加属性', en: 'Add Property' },
+ 'topic.removeProp': { zh: '删除第 {index} 个属性', en: 'Remove property {index}' },
'topic.confirmBatchDelete': { zh: '确认批量删除', en: 'Confirm Batch Delete' },
'topic.batchDeleteConfirm': {
zh: '确定要删除选中的 {count} 个 Topic 吗?此操作不可撤销。',
diff --git a/web/src/pages/instance/__tests__/TopicPage.test.tsx
b/web/src/pages/instance/__tests__/TopicPage.test.tsx
index 2821b9efd..68b926dee 100644
--- a/web/src/pages/instance/__tests__/TopicPage.test.tsx
+++ b/web/src/pages/instance/__tests__/TopicPage.test.tsx
@@ -1668,6 +1668,86 @@ describe('TopicPage', () => {
});
});
+ it.each([
+ { lang: 'zh', key: '{Enter}', removeLabel: '删除第 2 个属性' },
+ { lang: 'zh', key: ' ', removeLabel: '删除第 2 个属性' },
+ { lang: 'en', key: '{Enter}', removeLabel: 'Remove property 2' },
+ { lang: 'en', key: ' ', removeLabel: 'Remove property 2' },
+ ])(
+ 'removes the intended property with $key in $lang without sending Test',
+ async ({ lang, key, removeLabel }) => {
+ localStorage.setItem('rocketmq-studio-language', lang);
+ const user = userEvent.setup({ pointerEventsCheck: 0 });
+ mockTopicsList([buildTopics(1)[0]]);
+ renderWithProviders();
+
+ await user.click(await screen.findByRole('button', { name: /发送/ }));
+ const dialog = await getSendDialog();
+ fireEvent.change(within(dialog).getByLabelText('消息体 Body'), {
+ target: { value: '{"event":"created"}' },
+ });
+ for (let index = 0; index < 3; index += 1) {
+ await user.click(within(dialog).getByRole('button', { name: /添加属性/ }));
+ }
+ const propertyKeys = within(dialog).getAllByPlaceholderText('属性名');
+ const propertyValues = within(dialog).getAllByPlaceholderText('属性值');
+ ['traceId', 'traceId', 'route'].forEach((value, index) => {
+ fireEvent.change(propertyKeys[index], { target: { value } });
+ });
+ ['keep-first', 'remove-middle', 'keep-last'].forEach((value, index) => {
+ fireEvent.change(propertyValues[index], { target: { value } });
+ });
+
+ const submit = vi.fn((event: Event) => event.preventDefault());
+ dialog.querySelector('form')!.addEventListener('submit', submit);
+ act(() => propertyValues[1].focus());
+ await user.tab();
+ const removeButton = within(dialog).getByRole('button', { name:
removeLabel });
+ expect(removeButton).toHaveFocus();
+ expect(removeButton).toHaveAttribute('type', 'button');
+ expect(topicServiceMocks.sendTopicMessage).not.toHaveBeenCalled();
+ await user.keyboard(key);
+
+
expect(within(dialog).queryByDisplayValue('remove-middle')).not.toBeInTheDocument();
+ expect(within(dialog).getAllByPlaceholderText('属性名')).toHaveLength(2);
+
expect(within(dialog).getByDisplayValue('keep-first')).toBeInTheDocument();
+
expect(within(dialog).getByDisplayValue('keep-last')).toBeInTheDocument();
+ expect(within(dialog).getByRole('button', { name: removeLabel
})).toBeInTheDocument();
+ expect(submit).not.toHaveBeenCalled();
+ expect(topicServiceMocks.sendTopicMessage).not.toHaveBeenCalled();
+
+ await user.click(within(dialog).getByRole('button', { name: /发\s*送/ }));
+ await waitFor(() =>
expect(topicServiceMocks.sendTopicMessage).toHaveBeenCalledTimes(1));
+ expect(topicServiceMocks.sendTopicMessage).toHaveBeenCalledWith({
+ topic: 'topic-01',
+ instanceId: 'instance-proxy-1',
+ body: '{"event":"created"}',
+ properties: { traceId: 'keep-first', route: 'keep-last' },
+ });
+ },
+ );
+
+ it('keeps pointer removal from sending the message Test', async () => {
+ const user = userEvent.setup({ pointerEventsCheck: 0 });
+ mockTopicsList([buildTopics(1)[0]]);
+ renderWithProviders();
+
+ await user.click(await screen.findByRole('button', { name: /发送/ }));
+ const dialog = await getSendDialog();
+ await user.click(within(dialog).getByRole('button', { name: /添加属性/ }));
+ await user.click(within(dialog).getByRole('button', { name: /添加属性/ }));
+ const propertyValues = within(dialog).getAllByPlaceholderText('属性值');
+ fireEvent.change(propertyValues[0], { target: { value: 'keep' } });
+ fireEvent.change(propertyValues[1], { target: { value: 'remove' } });
+
+ await user.click(within(dialog).getAllByRole('img', { name: 'minus-circle'
})[1]);
+
+ expect(within(dialog).getAllByPlaceholderText('属性值')).toHaveLength(1);
+ expect(within(dialog).getByDisplayValue('keep')).toBeInTheDocument();
+
expect(within(dialog).queryByDisplayValue('remove')).not.toBeInTheDocument();
+ expect(topicServiceMocks.sendTopicMessage).not.toHaveBeenCalled();
+ });
+
it('blocks duplicate form properties when sending', async () => {
const user = userEvent.setup({ pointerEventsCheck: 0 });
mockTopicsList([buildTopics(1)[0]]);
diff --git a/web/src/pages/instance/topic.tsx b/web/src/pages/instance/topic.tsx
index 945e656a5..940a1ef25 100644
--- a/web/src/pages/instance/topic.tsx
+++ b/web/src/pages/instance/topic.tsx
@@ -1949,8 +1949,13 @@ const TopicPageContent = ({
</Form.Item>
</Col>
<Col span={4}>
- <MinusCircleOutlined
- style={{ color: '#ff4d4f', fontSize: 18, cursor:
'pointer' }}
+ <Button
+ type="text"
+ htmlType="button"
+ size="small"
+ danger
+ icon={<MinusCircleOutlined style={{ fontSize: 18 }}
/>}
+ aria-label={t('topic.removeProp', { index: name + 1
})}
onClick={() => remove(name)}
/>
</Col>