Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Cell Event Not Triggering in Univer API #4742

Open
2 tasks done
chuyinweilai opened this issue Feb 27, 2025 · 1 comment
Open
2 tasks done

[Bug] Cell Event Not Triggering in Univer API #4742

chuyinweilai opened this issue Feb 27, 2025 · 1 comment
Assignees
Labels
bug Something isn't working scope:facade

Comments

@chuyinweilai
Copy link

chuyinweilai commented Feb 27, 2025

Before you submit this issue, have you checked the following

  • Is this really a problem?
  • I have searched the Github Issues for similar issues, but did not find anything.

Affected packages and versions

V 0.6.1

Reproduction link

When attempting to listen to the CellClicked event using the Univer API, the event handler does not execute as expected.I have also tried CellHover and CellPointerMove, they does not work.
No error messages are being logged to the console related to event binding.

Other events, such as BeforeCommandExecute、BeforeSheetEditStart, function correctly.

Environment:

Univer Version: 0.6.1
Browser: Google Chrome 133.0.6943.99
React: 18.0.37

Code

import React, { useEffect, useRef } from 'react';
import {
  createUniver,
  defaultTheme,
  LocaleType,
  merge,
} from '@univerjs/presets';
import { UniverSheetsCorePreset } from '@univerjs/presets/preset-sheets-core';
import UniverPresetSheetsCoreZhCN from '@univerjs/presets/preset-sheets-core/locales/zh-CN';
import { UniverSheetsCrosshairHighlightPlugin } from '@univerjs/sheets-crosshair-highlight';
import SheetsCrosshairHighlightZhCN from '@univerjs/sheets-crosshair-highlight/locale/zh-CN';

import '@univerjs/presets/lib/styles/preset-sheets-core.css';
import '@univerjs/sheets-crosshair-highlight/facade';
import '@univerjs/sheets-crosshair-highlight/lib/index.css';
import SheetUtils from './SheetUtils';

const UniverJS = () => {
  const containerRef = useRef<HTMLDivElement>(null);

  useEffect(() => {
    if (!containerRef.current) return;
    // 初始化 Univer 插件
    const { univerAPI } = createUniver({
      locale: LocaleType.ZH_CN,
      locales: {
        [LocaleType.ZH_CN]: merge(
          UniverPresetSheetsCoreZhCN,
          SheetsCrosshairHighlightZhCN,
        ),
      },
      theme: defaultTheme,
      presets: [
        UniverSheetsCorePreset({
          container: containerRef.current,
        }),
      ],
      plugins: [UniverSheetsCrosshairHighlightPlugin],
    });
    // 创建工作簿
    univerAPI.createWorkbook(SheetUtils.defaultOption);

    univerAPI.addEvent(univerAPI.Event.BeforeSheetEditStart, () => {
      throw new Error('disabled');
    });
    univerAPI.addEvent(univerAPI.Event.CellClicked, (data) => {
      console.log('CellClicked', data);
    });
  }, [containerRef.current]);

  return (
    <div style={{ width: '100%', height: '100%' }} ref={containerRef}></div>
  );
};

export default UniverJS;

I found that you have already submitted related fixes, but the current version is still not effective.
Please let me know if you need any additional information or clarification!

Expected behavior

The CellClicked event should trigger when a cell is clicked, logging the event details to the console.

Actual behavior

No output is logged when cells are clicked, suggesting the event isn't being dispatched.

System information

No response

@univer-bot univer-bot bot added the bug Something isn't working label Feb 27, 2025
@univer-bot
Copy link

univer-bot bot commented Feb 27, 2025

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿

Origin Title: [Bug] Cell Event Not Triggering in Univer API

Title: [Bug] Cell Event Not Triggering in Univer API


Before you submit this issue, have you checked the following

  • Is this really a problem?
  • I have searched the Github Issues for similar issues, but did not find anything.

Affected packages and versions

V 0.6.1

Reproduction link

When attempting to listen to the CellClicked event using the Univer API, the event handler does not execute as expected.I have also tried CellHover and CellPointerMove, they does not work.
No error messages are being logged to the console related to event binding.

Other events, such as BeforeCommandExecute、BeforeSheetEditStart, function correctly.

Environment:

Univer Version: 0.6.1
Browser: Google Chrome 133.0.6943.99
React: 18.0.37

Code

I found that you have already submitted related fixes, but the current version is still not effective.
Please let me know if you need any additional information or clarification!

Expected behavior

The CellClicked event should trigger when a cell is clicked, logging the event details to the console.

Actual behavior

No output is logged when cells are clicked, suggesting the event isn't being dispatched.

System information

No response

@hexf00 hexf00 assigned weird94 and unassigned hexf00 Feb 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working scope:facade
Projects
None yet
Development

No branches or pull requests

4 participants