bigbluebutton / bigbluebutton-html-plugin-sdk

BigBlueButton Plugin SDK
GNU Lesser General Public License v3.0
7 stars 6 forks source link

feat: Add possible way of updating a component without changing it completely #125

Closed GuiLeme closed 1 week ago

GuiLeme commented 1 week ago

What does this PR do?

Add possible way of updating a component without changing it completely, that is setting id when constructing the object.

Motivation

The generic-content-items (mainly sidekick) were unmounting and then mounting again whenever one did update the extensible areas via setter function, and this caused weird behaviours even harming user experience. One interesting case is when the developer wants to build something like this in the plugin:

useEffect(() => {
  pluginApi.setGenericContentItems(
    [new GenericContentSidekickArea({
      contentFunction: variableContentFunction,
      name: variableTitle,
      section: 'Section of example',
      buttonIcon: 'user',
      open: false, // <-- this property is responsible to mount the sidekick menu, but if false, the panel itself will be closed.
      // On the other hand, if the property is true, right after the menu has mounted, the panel will open.
    })],
  );
  }, [variableTitle, variableContentFunction]);

What used to happen is:

Now, it is possible to send a specific id each time you call the setter function (pluginApi.setGenericContentItems), and with that fixed id the content and even the title can change, but it will not re-mount.

More:

Closely related to PR https://github.com/bigbluebutton/bigbluebutton/pull/21476