Skip to content

Build your own AI office with Univer Office SDK. Bring editing, calculation, collaboration, and file processing into your product for people and AI agents. Built on an extensible open-source core.

fix(sheets-data-validation): bugfix for data-validation (#2562)

zhangwd1e38dd15b98
diff --git a/packages/design/src/components/tooltip/Tooltip.stories.tsx b/packages/design/src/components/tooltip/Tooltip.stories.tsx
index 04ab9d38fd..6da696274d 100644
--- a/packages/design/src/components/tooltip/Tooltip.stories.tsx
+++ b/packages/design/src/components/tooltip/Tooltip.stories.tsx
@@ -45,6 +45,13 @@ export const Playground = {
<Button>bottom</Button>
</Tooltip>
</div>
+ <div>
+ <Tooltip showIfEllipsis title="hello world" placement="bottom">
+ <span style={{ overflow: 'hidden', textOverflow: 'ellipsis' }}>
+ showIfEllipsis: 奇奇怪怪乖乖跟琪琪去上课就开始丹江口市的是卡拉斯科独立思考独立思考
+ </span>
+ </Tooltip>
+ </div>
</>
);
},
diff --git a/packages/sheets-data-validation/src/controllers/dv-auto-fill.controller.ts b/packages/sheets-data-validation/src/controllers/dv-auto-fill.controller.ts
index 1a0e5a6661..af7ea0eb7c 100644
--- a/packages/sheets-data-validation/src/controllers/dv-auto-fill.controller.ts
+++ b/packages/sheets-data-validation/src/controllers/dv-auto-fill.controller.ts
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-import { Disposable, LifecycleStages, OnLifecycle, Range, Rectangle } from '@univerjs/core';
+import { DataValidationType, Disposable, LifecycleStages, OnLifecycle, Range, Rectangle } from '@univerjs/core';
import type { IAutoFillLocation, ISheetAutoFillHook } from '@univerjs/sheets-ui';
import { APPLY_TYPE, getAutoFillRepeatRange, IAutoFillService, virtualizeDiscreteRanges } from '@univerjs/sheets-ui';
import { Inject } from '@wendellhu/redi';
@@ -101,8 +101,24 @@ export class DataValidationAutoFillController extends Disposable {
redos: redoMutations,
};
};
+ const disabledDataVallation = [
+ DataValidationType.CHECKBOX,
+ ];
const hook: ISheetAutoFillHook = {
id: DATA_VALIDATION_PLUGIN_NAME,
+ onBeforeFillData: (location) => {
+ const { source: sourceRange, unitId, subUnitId } = location;
+ const manager = this._dataValidationModel.ensureManager(unitId, subUnitId) as SheetDataValidationManager;
+ for (const row of sourceRange.rows) {
+ for (const col of sourceRange.cols) {
+ const dv = manager.getRuleByLocation(row, col);
+ if (dv && disabledDataVallation.indexOf(dv.type) > -1) {
+ this._autoFillService.setDisableApplyType(APPLY_TYPE.SERIES, true);
+ return;
+ }
+ }
+ }
+ },
onFillData: (location, direction, applyType) => {
if (
applyType === APPLY_TYPE.COPY ||
@@ -114,6 +130,9 @@ export class DataValidationAutoFillController extends Disposable {
return noopReturnFunc();
},
+ onAfterFillData: () => {
+ this._autoFillService.setDisableApplyType(APPLY_TYPE.SERIES, false);
+ },
};
this.disposeWithMe(this._autoFillService.addHook(hook));
}
diff --git a/packages/sheets-data-validation/src/widgets/dropdown-widget.ts b/packages/sheets-data-validation/src/widgets/dropdown-widget.ts
index 373dbdee2d..a5ff899d99 100644
--- a/packages/sheets-data-validation/src/widgets/dropdown-widget.ts
+++ b/packages/sheets-data-validation/src/widgets/dropdown-widget.ts
@@ -189,14 +189,14 @@ export class DropdownWidget implements IBaseDataValidationWidget {
private _drawDownIcon(ctx: UniverRenderingContext2D, cellBounding: { startX: number; startY: number }, cellWidth: number, cellHeight: number, vt: VerticalAlign) {
const left = cellWidth - ICON_PLACE + 4;
- let top = 4;
+ let top = 9;
switch (vt) {
case VerticalAlign.MIDDLE:
- top = (cellHeight - ICON_PLACE) / 2 + 4;
+ top = ((cellHeight - ICON_PLACE) / 2) + 4;
break;
case VerticalAlign.BOTTOM:
- top = (cellHeight - ICON_PLACE) + 4;
+ top = (cellHeight - ICON_PLACE) - 1;
break;
default:
break;
diff --git a/packages/sheets-hyper-link-ui/src/locale/en-US.ts b/packages/sheets-hyper-link-ui/src/locale/en-US.ts
index c2f36252ea..ab836f44e4 100644
--- a/packages/sheets-hyper-link-ui/src/locale/en-US.ts
+++ b/packages/sheets-hyper-link-ui/src/locale/en-US.ts
@@ -28,7 +28,7 @@ const enUS: typeof zhCN = {
range: 'Range',
worksheet: 'Worksheet',
definedName: 'Defined Name',
- ok: 'OK',
+ ok: 'Confirm',
cancel: 'Cancel',
labelPlaceholder: 'Enter label',
inputError: 'Please enter',
diff --git a/packages/sheets-hyper-link-ui/src/services/popup.service.ts b/packages/sheets-hyper-link-ui/src/services/popup.service.ts
index f6814a4442..37dfa1b383 100644
--- a/packages/sheets-hyper-link-ui/src/services/popup.service.ts
+++ b/packages/sheets-hyper-link-ui/src/services/popup.service.ts
@@ -93,6 +93,9 @@ export class SheetsHyperLinkPopupService extends Disposable {
componentKey: CellLinkPopup.componentKey,
direction: 'bottom',
closeOnSelfTarget: true,
+ onClickOutside: () => {
+ this.hideCurrentPopup();
+ },
});
if (disposable) {
this._currentPopup = {
diff --git a/packages/sheets-hyper-link-ui/src/views/CellLinkPopup/index.module.less b/packages/sheets-hyper-link-ui/src/views/CellLinkPopup/index.module.less
index 6869fe1b64..5a722a84ae 100644
--- a/packages/sheets-hyper-link-ui/src/views/CellLinkPopup/index.module.less
+++ b/packages/sheets-hyper-link-ui/src/views/CellLinkPopup/index.module.less
@@ -73,6 +73,7 @@
cursor: pointer;
border-radius: 4px;
}
+
.cell-link-operation-error {
color: rgb(var(--grey-500));
}
diff --git a/packages/sheets-hyper-link-ui/src/views/CellLinkPopup/index.tsx b/packages/sheets-hyper-link-ui/src/views/CellLinkPopup/index.tsx
index f2c997253b..f833d1885c 100644
--- a/packages/sheets-hyper-link-ui/src/views/CellLinkPopup/index.tsx
+++ b/packages/sheets-hyper-link-ui/src/views/CellLinkPopup/index.tsx
@@ -62,9 +62,9 @@ export const CellLinkPopup = () => {
<div className={styles.cellLinkType}>
{iconsMap[linkObj.type]}
</div>
- <div className={styles.cellLinkUrl}>
- {linkObj.name}
- </div>
+ <Tooltip showIfEllipsis title={linkObj.name}>
+ <span className={styles.cellLinkUrl}>{linkObj.name}</span>
+ </Tooltip>
</div>
<div className={styles.cellLinkOperations}>
{currentPopup.copyPermission && (
diff --git a/packages/sheets/src/services/ref-range/util.ts b/packages/sheets/src/services/ref-range/util.ts
index a2ed8f27be..e70ad1dfb3 100644
--- a/packages/sheets/src/services/ref-range/util.ts
+++ b/packages/sheets/src/services/ref-range/util.ts
@@ -258,10 +258,9 @@ export const handleMoveRowsCommon = (params: IMoveRowsCommand, targetRange: IRan
return [targetRange];
}
- const { startRow: fromRow } = fromRange;
- const { startRow: toRow } = toRange;
-
- const count = toRange.endRow - toRange.startRow + 1;
+ const fromRow = fromRange.startRow;
+ const count = fromRange.endRow - fromRange.startRow + 1;
+ const toRow = toRange.startRow;
const matrix = new ObjectMatrix();
@@ -336,10 +335,9 @@ export const handleMoveColsCommon = (params: IMoveColsCommand, targetRange: IRan
return [targetRange];
}
- const { startColumn: fromCol } = fromRange;
- const { startColumn: toCol } = toRange;
-
- const count = toRange.endColumn - toRange.startColumn + 1;
+ const fromCol = fromRange.startColumn;
+ const count = fromRange.endColumn - fromRange.startColumn + 1;
+ const toCol = toRange.startColumn;
const matrix = new ObjectMatrix();