Skip to content

Commit

Permalink
BUGFIX: Prevent warnings for unrecognized DOM props
Browse files Browse the repository at this point in the history
This change addresses React warnings related to invalid DOM attributes:
- Removed `executeCommand` and `formattingUnderCursor` from being passed to DOM elements.
- Ensured these props are only handled within components where they are relevant, preventing them from being incorrectly rendered on DOM elements.

These update prevent unnecessary warnings in the console.

Resolves: #3894
  • Loading branch information
markusguenther committed Dec 10, 2024
1 parent 0e6c71c commit 6b63d53
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export default richtextToolbarRegistry => {
const restProps = omit(props, ['isVisible', 'isActive']);
const isActiveProp = isToolbarItemActive(formattingUnderCursor, inlineEditorOptions)(componentDefinition);

const finalProps = {
let finalProps = {
...restProps,
key: index,
isActive: isActiveProp,
Expand All @@ -41,6 +41,11 @@ export default richtextToolbarRegistry => {
[callbackPropName]: e => e.stopPropagation() || executeCommand(commandName, ...commandArgs)
};

// filter out props that are not needed by the component and lead to a render warning
if (commandName === 'code') {
finalProps = omit(finalProps, ['executeCommand', 'formattingUnderCursor']);
}

const Component = component;

return <Component {...finalProps} />;
Expand Down

0 comments on commit 6b63d53

Please sign in to comment.