Skip to content
This repository has been archived by the owner on Oct 23, 2023. It is now read-only.

Commit

Permalink
fix: restore element name editing
Browse files Browse the repository at this point in the history
  • Loading branch information
marionebl authored and tilmx committed May 28, 2018
1 parent 10ee949 commit 8c47f72
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/container/element-list/element-container.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import * as AlvaUtil from '../../alva-util';
import * as Components from '../../components';
import { ElementContentContainer } from './element-content-container';
import * as MobxReact from 'mobx-react';
Expand All @@ -12,6 +13,8 @@ export interface ElementContainerProps {
export class ElementContainer extends React.Component<ElementContainerProps> {
public render(): JSX.Element | null {
const { props } = this;
const open =
props.element.getOpen() || props.element.getDescendants().some(e => e.getSelected());
return (
<Components.Element
active={props.element.getSelected()}
Expand All @@ -22,12 +25,11 @@ export class ElementContainer extends React.Component<ElementContainerProps> {
highlightPlaceholder={props.element.getPlaceholderHighlighted()}
id={props.element.getId()}
mayOpen={props.element.acceptsChildren()}
open={
props.element.getOpen() || props.element.getDescendants().some(e => e.getSelected())
}
open={open}
onChange={AlvaUtil.noop}
title={props.element.getName()}
>
{props.element.getOpen()
{open
? props.element
.getContents()
.map(content => (
Expand Down
10 changes: 10 additions & 0 deletions src/container/element-list/element-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,15 @@ export class ElementList extends React.Component {
}
}

private handleChange(e: React.FormEvent<HTMLElement>): void {
const target = e.target as HTMLInputElement;
const changedElement = elementFromTarget(e.target, { sibling: false });

if (changedElement) {
changedElement.setName(target.value);
}
}

private handleClick(e: React.MouseEvent<HTMLElement>): void {
const target = e.target as HTMLElement;
const icon = above(target, `svg[${ElementAnchors.icon}]`);
Expand Down Expand Up @@ -329,6 +338,7 @@ export class ElementList extends React.Component {
data-drag-root
{...{ [ElementAnchors.element]: rootElement.getId() }}
onBlur={e => this.handleBlur(e)}
onChange={e => this.handleChange(e)}
onClick={e => this.handleClick(e)}
onContextMenu={e => this.handleContextMenu(e)}
onDragEnd={e => this.handleDragEnd(e)}
Expand Down

0 comments on commit 8c47f72

Please sign in to comment.