codeant-ai-for-open-source[bot] commented on code in PR #38524:
URL: https://github.com/apache/superset/pull/38524#discussion_r2939437347
##########
superset-frontend/packages/superset-ui-core/src/components/EditableTitle/index.tsx:
##########
@@ -89,11 +89,20 @@ export function EditableTitle({
onEditingChange,
...rest
}: EditableTitleProps) {
- const [isEditing, setIsEditing] = useState(editing);
+ const isControlled = editing !== undefined;
+ const [isEditingInternal, setIsEditingInternal] = useState(editing ?? false);
Review Comment:
**Suggestion:** The new controlled/uncontrolled detection is incorrect
because `editing` is always defined (it defaults to `false`), so the component
always behaves as controlled and never updates internal editing state on click.
This breaks existing callers that do not pass `editing`, making titles no
longer enter edit mode. Detect controlled mode using an explicit control signal
instead of `editing !== undefined`. [logic error]
<details>
<summary><b>Severity Level:</b> Major ⚠️</summary>
```mdx
- ⚠️ Dashboard header titles never show active editing state.
- ⚠️ Datasource column renaming lacks editing affordance styling.
- ⚠️ EditableTitle click-to-edit regression test behavior breaks.
```
</details>
```suggestion
const isControlled = onEditingChange !== undefined || editing;
const [isEditingInternal, setIsEditingInternal] = useState(editing ??
false);
```
<details>
<summary><b>Steps of Reproduction ✅ </b></summary>
```mdx
1. Enter dashboard edit mode so `Header` renders `EditableTitle` with
`canEdit={editMode}`
but without `editing`/`onEditingChange`
(`superset-frontend/src/dashboard/components/gridComponents/Header/Header.tsx:286-290`).
2. In `EditableTitle`, destructuring sets `editing = false`
(`.../EditableTitle/index.tsx:75`) and `isControlled = editing !== undefined`
(`.../EditableTitle/index.tsx:92`), making controlled mode always true.
3. Click the title input, which runs `handleClick()`
(`.../EditableTitle/index.tsx:146-155`) and calls `setEditingState(true)`;
`setEditingState` skips `setIsEditingInternal` because `isControlled` is
true and no
parent callback exists (`.../EditableTitle/index.tsx:100-105`).
4. Observe `isEditing` remains false, so edit styling never activates
(`variant={isEditing
? 'outlined' : 'borderless'}` at `.../EditableTitle/index.tsx:226`); this
matches
regression covered by existing test expecting outlined mode on click
(`.../EditableTitle/EditableTitle.test.tsx:51-57`).
```
</details>
<details>
<summary><b>Prompt for AI Agent 🤖 </b></summary>
```mdx
This is a comment left during a code review.
**Path:**
superset-frontend/packages/superset-ui-core/src/components/EditableTitle/index.tsx
**Line:** 92:93
**Comment:**
*Logic Error: The new controlled/uncontrolled detection is incorrect
because `editing` is always defined (it defaults to `false`), so the component
always behaves as controlled and never updates internal editing state on click.
This breaks existing callers that do not pass `editing`, making titles no
longer enter edit mode. Detect controlled mode using an explicit control signal
instead of `editing !== undefined`.
Validate the correctness of the flagged issue. If correct, How can I resolve
this? If you propose a fix, implement it and please make it concise.
```
</details>
<a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F38524&comment_hash=0f6031021d2c53227b459c9f706ed1d75704dd15b5d25df271d10d09521c20ff&reaction=like'>👍</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F38524&comment_hash=0f6031021d2c53227b459c9f706ed1d75704dd15b5d25df271d10d09521c20ff&reaction=dislike'>👎</a>
--
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]