mirror of
https://github.com/dream-num/univer.git
synced 2026-09-19 02:18:42 +08:00
fix(docs-ui): align IME input with cursor (#7256)
This commit is contained in:
+14
@@ -1300,6 +1300,7 @@ describe('DocSelectionRenderService', () => {
|
||||
};
|
||||
const { renderUnit, service, univer } = createRealSelectionRenderService({ scene });
|
||||
cleanup.push(() => renderUnit.dispose(), () => univer.dispose());
|
||||
vi.spyOn(TestLayoutService.root, 'getBoundingClientRect').mockReturnValue({ left: 100, top: 200 } as DOMRect);
|
||||
const activeRange = {
|
||||
isActive: () => true,
|
||||
getAnchor: () => ({ left: 12, top: 20, visible: true }),
|
||||
@@ -1315,6 +1316,19 @@ describe('DocSelectionRenderService', () => {
|
||||
expect(container.style.zIndex).toBe('1000');
|
||||
});
|
||||
|
||||
it('converts the hidden editor position for a fixed containing block', () => {
|
||||
const { renderUnit, service, univer } = createRealSelectionRenderService();
|
||||
cleanup.push(() => renderUnit.dispose(), () => univer.dispose());
|
||||
const container = document.getElementById('univer-doc-selection-container-selection-render-doc')!;
|
||||
vi.spyOn(container, 'offsetParent', 'get').mockReturnValue(TestLayoutService.root);
|
||||
vi.spyOn(TestLayoutService.root, 'getBoundingClientRect').mockReturnValue({ left: 100, top: 200 } as DOMRect);
|
||||
|
||||
service.activate(35, 47);
|
||||
|
||||
expect(container.style.left).toBe('-65px');
|
||||
expect(container.style.top).toBe('-153px');
|
||||
});
|
||||
|
||||
it('parks the active selection while scrolling and restores the editor when the selection remains in view', () => {
|
||||
getCanvasOffsetByEngineMock.mockReturnValue({ left: 1, top: 2 });
|
||||
const scrollAfter$ = new TestRenderEvent<{ viewport: unknown }>();
|
||||
|
||||
@@ -372,16 +372,13 @@ export class DocSelectionRenderService extends RxDisposable implements IRenderMo
|
||||
this._updateInputPosition();
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
activate(x: number, y: number, force = false) {
|
||||
// Keep the hidden editor inside the Portal subtree when possible to avoid focus-trap loops,
|
||||
// then compensate coordinates if a transformed ancestor changes the fixed containing block.
|
||||
this._ensureHostContainer();
|
||||
let left = x;
|
||||
let top = y;
|
||||
const fixedContainer = this._container.parentElement;
|
||||
const fixedContainer = this._container.offsetParent;
|
||||
if (fixedContainer) {
|
||||
const rect = fixedContainer.getBoundingClientRect();
|
||||
left -= rect.left;
|
||||
|
||||
Reference in New Issue
Block a user