8000 customButtons set by plugins are being overwritten · Issue #499 · vkurko/calendar · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

customButtons set by plugins are being overwritten #499

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

Open
tmpie opened this issue May 20, 2025 · 3 comments
Open

customButtons set by plugins are being overwritten #499

tmpie opened this issue May 20, 2025 · 3 comments

Comments

@tmpie
Copy link
tmpie commented May 20, 2025

In the plugin I am currently developing, I add customButtons with custom functionality, and they are working as intended.

However, when users define their own customButtons, it seems that all previously defined custom buttons are overwritten by the user’s settings.

Would it be possible to change this behavior so that the plugin-defined customButtons and the user-defined customButtons are merged instead of replaced?

@vkurko
Copy link
Owner
vkurko commented May 20, 2025

I need to think about some kind of universal approach here, because you need customButtons, and someone else will need a different option, etc. Can you share the source code of your plugin?

@tmpie
Copy link
Author
tmpie commented May 20, 2025

Thank you for your response.

My plugin is quite simple — it just toggles fullscreen mode. Here is the relevant code:

const Fullscreen = {
  createOptions(options) {
    options.customButtons['fullscreen'] = {
      text: 'FS',
      click: (e) => {
        if (document.fullscreenElement) {
          document.exitFullscreen();
        } else {
          e.target.closest('.ec').requestFullscreen();
        }
      },
    };
  },
};

When the user does not define customButtons in the createCalendar options, the plugin works as expected and the fullscreen button appears.

However, if a user defines their own customButtons like in the example below, the button does not display correctly:

const ec = createCalendar(
  document.getElementById('ec'),
  [DayGrid, Fullscreen],
  {
    headerToolbar: { start: 'prev,next today', center: 'title', end: 'dayGridMonth myButton fullscreen' },
    customButtons: {
      myButton: { text: 'My Button', click: () => {} },
    },
    ...
  }
);

@vkurko
Copy link
Owner
vkurko commented May 21, 2025

Thank you for sharing your code. I'll try to come up with a solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants
0