🐛 fix(query-editor): 修复选择器与事务提示浮层

- host 和数据库下拉选项关闭原生 title,避免和自定义 Tooltip 重复显示
- 事务模式说明默认向上弹出,并保留边界自动避让
- 移除下拉打开时强制隐藏事务说明的状态控制
- 补充工具栏和事务设置回归断言
This commit is contained in:
Syngnat
2026-06-26 10:06:56 +08:00
parent 22cdeb677b
commit faa7ed1ae2
4 changed files with 20 additions and 41 deletions

View File

@@ -96,6 +96,7 @@ describe('QueryEditorToolbar layout', () => {
expect(toolbarSource).toContain('mouseEnterDelay={FULL_NAME_TOOLTIP_DELAY_SECONDS}');
expect(toolbarSource).toContain('renderFullNameSelectTooltip');
expect(toolbarSource).toContain('gn-query-toolbar-select-full-name');
expect(toolbarSource).toContain('title: ""');
expect(connectionSelectSource).toContain('optionRender={(option) => renderFullNameSelectTooltip(option.data.fullName)}');
expect(connectionSelectSource).toContain('labelRender={(option) => renderFullNameSelectTooltip(option.label ?? option.value)}');
expect(databaseSelectSource).toContain('optionRender={(option) => renderFullNameSelectTooltip(option.data.fullName)}');

View File

@@ -60,6 +60,7 @@ const FULL_NAME_TOOLTIP_DELAY_SECONDS = 1;
type FullNameSelectOption = {
label: string;
value: string;
title: string;
fullName: string;
};
@@ -120,11 +121,13 @@ const QueryEditorToolbar: React.FC<QueryEditorToolbarProps> = ({
queryCapableConnections.map((connection) => ({
label: connection.name,
value: connection.id,
title: "",
fullName: connection.name,
}));
const databaseSelectOptions: FullNameSelectOption[] = dbList.map((db) => ({
label: db,
value: db,
title: "",
fullName: db,
}));
const toggleResultPanelShortcutLabel =

View File

@@ -26,7 +26,6 @@ vi.mock('../i18n/provider', () => ({
}),
}));
const latestSelectProps = () => antdState.selectProps[antdState.selectProps.length - 1];
const latestTooltipProps = () => antdState.tooltipProps[antdState.tooltipProps.length - 1];
describe('QueryEditorTransactionSettings', () => {
@@ -42,7 +41,7 @@ describe('QueryEditorTransactionSettings', () => {
renderer = null;
});
it('hides the DBeaver reference tooltip while the transaction mode select is open', () => {
it('keeps the DBeaver reference tooltip above the transaction mode select', () => {
act(() => {
renderer = create(
<QueryEditorTransactionSettings
@@ -55,20 +54,9 @@ describe('QueryEditorTransactionSettings', () => {
);
});
act(() => {
latestTooltipProps().onOpenChange(true);
});
expect(latestTooltipProps().open).toBe(true);
act(() => {
latestSelectProps().onOpenChange(true);
});
expect(latestTooltipProps().open).toBe(false);
act(() => {
latestSelectProps().onOpenChange(false);
latestTooltipProps().onOpenChange(true);
});
expect(latestTooltipProps().open).toBe(true);
expect(latestTooltipProps().placement).toBe('topLeft');
expect(latestTooltipProps()).not.toHaveProperty('autoAdjustOverflow', false);
expect(latestTooltipProps()).not.toHaveProperty('open');
expect(antdState.selectProps[0]).not.toHaveProperty('onOpenChange');
});
});

View File

@@ -35,42 +35,29 @@ const QueryEditorTransactionSettings: React.FC<QueryEditorTransactionSettingsPro
}) => {
const i18n = useOptionalI18n();
const t = i18n?.t ?? defaultTranslate;
const [isModeSelectOpen, setIsModeSelectOpen] = React.useState(false);
const [isModeTooltipOpen, setIsModeTooltipOpen] = React.useState(false);
const autoCommitDelayOptions = SQL_EDITOR_AUTO_COMMIT_DELAY_OPTIONS.map((option) => ({
value: option.value,
label: option.value === 0
? t('query_editor.transaction.delay.immediate_commit')
: t('query_editor.transaction.delay.seconds_commit', { seconds: Math.round(option.value / 1000) }),
}));
const handleModeSelectOpenChange = (open: boolean) => {
setIsModeSelectOpen(open);
if (open) {
setIsModeTooltipOpen(false);
}
};
const handleModeTooltipOpenChange = (open: boolean) => {
setIsModeTooltipOpen(open);
};
return (
<>
<Tooltip
title={t('query_editor.transaction.mode.tooltip')}
open={isModeTooltipOpen && !isModeSelectOpen}
onOpenChange={handleModeTooltipOpenChange}
placement="topLeft"
>
<Select
className={isV2Ui ? 'gn-v2-query-toolbar-select gn-v2-query-toolbar-transaction-mode-select' : undefined}
style={isV2Ui ? undefined : { width: 78 }}
value={commitMode}
onOpenChange={handleModeSelectOpenChange}
onChange={(mode) => onCommitModeChange(mode === 'auto' ? 'auto' : 'manual')}
options={[
{ label: t('query_editor.transaction.mode.manual'), value: 'manual' },
{ label: t('query_editor.transaction.mode.auto'), value: 'auto' },
]}
/>
<Select
className={isV2Ui ? 'gn-v2-query-toolbar-select gn-v2-query-toolbar-transaction-mode-select' : undefined}
style={isV2Ui ? undefined : { width: 78 }}
value={commitMode}
onChange={(mode) => onCommitModeChange(mode === 'auto' ? 'auto' : 'manual')}
options={[
{ label: t('query_editor.transaction.mode.manual'), value: 'manual' },
{ label: t('query_editor.transaction.mode.auto'), value: 'auto' },
]}
/>
</Tooltip>
{commitMode === 'auto' && (
<Select