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

Commit

Permalink
feat: make elements deselectable
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexpeschel committed Dec 12, 2017
1 parent af7587d commit c92c309
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
9 changes: 7 additions & 2 deletions src/component/container/element_list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,13 @@ export class ElementList extends React.Component<ElementListProps> {
const patternPath: string = element.getPatternPath() as string;

const updatePageElement: React.MouseEventHandler<HTMLElement> = event => {
event.stopPropagation();
this.props.store && this.props.store.setSelectedElement(element);
if (this.props.store.getSelectedElement() === element) {
event.stopPropagation();
this.props.store && this.props.store.unsetSelectedElement();
} else {
event.stopPropagation();
this.props.store && this.props.store.setSelectedElement(element);
}
};

return {
Expand Down
6 changes: 5 additions & 1 deletion src/store/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export class Store {
@MobX.observable private patternSearchTerm: string = '';
@MobX.observable private projects: Map<string, Project> = new Map();
@MobX.observable private patternRoot: PatternFolder;
@MobX.observable private selectedElement?: PageElement;
@MobX.observable private selectedElement?: PageElement | undefined;
@MobX.observable private styleGuidePath: string;

public getCurrentPage(): Page | undefined {
Expand Down Expand Up @@ -134,4 +134,8 @@ export class Store {
public setSelectedElement(selectedElement: PageElement): void {
this.selectedElement = selectedElement;
}

public unsetSelectedElement(): void {
this.selectedElement = undefined;
}
}

0 comments on commit c92c309

Please sign in to comment.