minor folder edit fixes

pull/1642/head
gabrielburnworth 2019-12-27 10:38:29 -08:00
parent 22465a5558
commit 1455bebba2
4 changed files with 11 additions and 3 deletions

View File

@ -15,6 +15,7 @@ const BLACKLIST: ResourceName[] = [
"WebAppConfig",
"WebcamFeed",
"Alert",
"Folder",
];
export function maybeStartTracking(uuid: string) {

View File

@ -351,6 +351,7 @@ describe("<FolderNameInput />", () => {
currentTarget: { value: "new name" }
});
expect(setFolderName).toHaveBeenCalledWith(p.node.id, "new name");
expect(toggleFolderEditState).toHaveBeenCalledWith(p.node.id);
});
it("closes folder name input", () => {

View File

@ -132,8 +132,11 @@ export const FolderButtonCluster =
export const FolderNameInput = ({ node }: FolderNameInputProps) =>
<div className="folder-name-input">
<BlurableInput value={node.name} onCommit={e =>
setFolderName(node.id, e.currentTarget.value)} />
<BlurableInput value={node.name} autoFocus={true} autoSelect={true}
onCommit={e => {
setFolderName(node.id, e.currentTarget.value);
toggleFolderEditState(node.id);
}} />
<button
className="fb-button green"
onClick={() => toggleFolderEditState(node.id)}>

View File

@ -29,6 +29,7 @@ export interface BIProps {
error?: string;
title?: string;
autoFocus?: boolean;
autoSelect?: boolean;
}
interface BIState {
@ -79,8 +80,10 @@ export class BlurableInput extends React.Component<BIProps, Partial<BIState>> {
this.setState({ isEditing: false, buffer: "", error: undefined });
}
focus = () => {
focus = (e: React.FocusEvent<HTMLInputElement>) => {
const { value } = this.props;
this.props.autoSelect &&
e.target.setSelectionRange(0, e.target.value.length);
this.setState({
isEditing: true,
buffer: "" + (value || ""),