Skip to content

Conversation

@gloaysa
Copy link
Contributor

@gloaysa gloaysa commented Jan 4, 2025

Description

Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.

Fixes # (issue)
#273

Type of change

Please tick the relevant option.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Checklist:

  • I have performed a self-review of my own code
  • I have commented on my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have checked my code and corrected any misspellings

Screenshots:

Screen.Recording.2025-01-04.at.17.10.45.mov

@vercel
Copy link

vercel bot commented Jan 4, 2025

@gloaysa is attempting to deploy a commit to the dargo's projects Team on Vercel.

A member of the Team first needs to authorize it.

if (render) {
return (
// [TODO] - take care about SSR
const menuContent = render ? render({ ...renderProps, actions: blockTypes }) : <DefaultActionMenuRender {...renderProps} actions={blockTypes} />;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The original code conditionally skips parts of the component tree based on render, which changes the structure React expects, violating the Rules of Hooks; the fix ensures consistent structure by dynamically selecting content via a variable.

I hope is ok, had to tackle this issue on this PR since it was introducing a bug (I'm using the new useTranslate hook in the conditionally rendered children DefaultActionMenuRender).

});

const blockTypes: ActionMenuToolItem[] = mapActionMenuItems(editor, items || Object.keys(editor.blocks));
const blockTypes = useMemo(() => mapActionMenuItems(editor, items || Object.keys(editor.blocks)), [editor, items]);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is not directly related to my feature, I'm just following the boy-scout rule.

I've noticed that this is recalculated on every render. If editor or items doesn’t change, this causes unnecessary re-renders.


useEffect(() => {
setActions(blockTypes);
setSelectedAction(blockTypes[0]);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is not directly related to my feature, I'm just following the boy-scout rule.

If loading actions dynamically, the list wasn't being updated. This change syncs the actions if the blockTypes change.

@gloaysa gloaysa changed the title feat: first draft at implementing translations feat: implementing translations api Jan 5, 2025
@gloaysa gloaysa marked this pull request as ready for review January 5, 2025 12:59
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

Successfully merging this pull request may close these issues.

2 participants