msyavuz commented on code in PR #38524:
URL: https://github.com/apache/superset/pull/38524#discussion_r2939243062
##########
superset-frontend/packages/superset-ui-core/src/components/EditableTitle/index.tsx:
##########
@@ -105,15 +105,19 @@ export function EditableTitle({
return 0;
}
- useEffect(() => {
+ useLayoutEffect(() => {
const { font } = window.getComputedStyle(
contentRef.current?.resizableTextArea?.textArea || document.body,
);
const textWidth = measureTextWidth(currentTitle || '', font);
const padding = 20;
const maxAllowedWidth = typeof maxWidth === 'number' ? maxWidth : Infinity;
setInputWidth(Math.min(textWidth + padding, maxAllowedWidth));
- }, [currentTitle]);
+ }, [currentTitle, maxWidth]);
+
+ useEffect(() => {
+ setIsEditing(editing);
+ }, [editing]);
Review Comment:
This seems a bit weird.
Reference:
https://react.dev/learn/you-might-not-need-an-effect#updating-state-based-on-props-or-state
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]