Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
pre-commit-ci[bot] committed Dec 2, 2024
1 parent d6882ea commit 40cb877
Showing 1 changed file with 51 additions and 43 deletions.
94 changes: 51 additions & 43 deletions packages/base/src/panelview/objecttree.tsx
Original file line number Diff line number Diff line change
@@ -470,52 +470,60 @@ class ObjectTreeReact extends React.Component<IProps, IStates> {
}}
onClick={() => this.setState({ editingNode: opts.node.id })}
>
{this.state.editingNode === opts.node.id ? (
<input
type="text"
value={this.state.editingNodeValue || opts.node.label}
autoFocus
onBlur={() => this.setState({ editingNode: null })}
onChange={(e) =>
this.setState({ editingNodeValue: e.target.value })
}
onKeyDown={(e) => {
if (e.key === 'Enter') {
console.log('Updated name:', this.state.editingNodeValue);
const updatedName = this.state.editingNodeValue;
const objectName = opts.node.id;

if(this.props.cpModel.mainViewModel) {
const obj = this.props.cpModel.jcadModel?.sharedModel.getObjectByName(objectName as string);
if (obj) {
this.props.cpModel.sharedModel?.updateObjectByName(objectName as string, {
data: {
key: 'name',
value: updatedName
}
{this.state.editingNode === opts.node.id ? (
<input
type="text"
value={this.state.editingNodeValue || opts.node.label}
autoFocus
onBlur={() => this.setState({ editingNode: null })}
onChange={e =>
this.setState({ editingNodeValue: e.target.value })
}
onKeyDown={e => {
if (e.key === 'Enter') {
console.log(
'Updated name:',
this.state.editingNodeValue
);
const updatedName = this.state.editingNodeValue;
const objectName = opts.node.id;

if (this.props.cpModel.mainViewModel) {
const obj =
this.props.cpModel.jcadModel?.sharedModel.getObjectByName(
objectName as string
);
if (obj) {
this.props.cpModel.sharedModel?.updateObjectByName(
objectName as string,
{
data: {
key: 'name',
value: updatedName
}
}
);
}
);
}
this.setState({
editingNode: null,
editingNodeValue: null
});
}
this.setState({
editingNode: null,
editingNodeValue: null
});
}
}}
style={{
width: '100%',
background: 'transparent',
border: 'none',
outline: 'none',
fontSize: 'inherit',
color: 'inherit'
}}
/>
) : (
opts.node.label
)}
</span>
}}
style={{
width: '100%',
background: 'transparent',
border: 'none',
outline: 'none',
fontSize: 'inherit',
color: 'inherit'
}}
/>
) : (
opts.node.label
)}
</span>
{opts.type === 'leaf' ? (
<div style={{ display: 'flex' }}>
<ToolbarButtonComponent

0 comments on commit 40cb877

Please sign in to comment.