diff --git a/CHANGELOG.unreleased.md b/CHANGELOG.unreleased.md index 4cf4a214d0b..bacca918474 100644 --- a/CHANGELOG.unreleased.md +++ b/CHANGELOG.unreleased.md @@ -24,6 +24,7 @@ For upgrade instructions, please check the [migration guide](MIGRATIONS.released - When proofreading segments and merging two segments, the segment item that doesn't exist anymore after the merge is automatically removed. [#7729](https://github.com/scalableminds/webknossos/pull/7729) - Changed some internal APIs to use spelling dataset instead of dataSet. This requires all connected datastores to be the latest version. [#7690](https://github.com/scalableminds/webknossos/pull/7690) - Toasts are shown until WEBKNOSSOS is running in the active browser tab again. Also, the content of most toasts that show errors or warnings is printed to the browser's console. [#7741](https://github.com/scalableminds/webknossos/pull/7741) +- Improved UI speed when editing the description of an annotation. [#7769](https://github.com/scalableminds/webknossos/pull/7769) ### Fixed - Fixed that the Command modifier on MacOS wasn't treated correctly for some shortcuts. Also, instead of the Alt key, the ⌥ key is shown as a hint in the status bar on MacOS. [#7659](https://github.com/scalableminds/webknossos/pull/7659) diff --git a/frontend/javascripts/oxalis/view/components/editable_text_label.tsx b/frontend/javascripts/oxalis/view/components/editable_text_label.tsx index b0cf1223c45..e0a00edc18e 100644 --- a/frontend/javascripts/oxalis/view/components/editable_text_label.tsx +++ b/frontend/javascripts/oxalis/view/components/editable_text_label.tsx @@ -59,12 +59,20 @@ class EditableTextLabel extends React.PureComponent) => { + handleInputChangeFromEvent = ( + event: React.ChangeEvent, + ) => { this.setState({ value: event.target.value, }); }; + handleInputChange = (newValue: string) => { + this.setState({ + value: newValue, + }); + }; + handleOnChange = () => { const validateAndUpdateValue = () => { if (this.validateFields()) { @@ -120,7 +128,7 @@ class EditableTextLabel extends React.PureComponent void; - onChange: React.ChangeEventHandler; + onChange: (newValue: string) => void; }) { const placeholderText = placeholder ? placeholder : `Add ${label}`; + const [currentValue, setCurrentValue] = React.useState(source); + + const onConfirm = () => { + onChange(currentValue); + onOk(); + }; + + const setCurrentValueFromEvent = ( + event: React.ChangeEvent, + ) => { + setCurrentValue(event.target.value); + }; + return ( {`Edit ${label}`}} open={isOpen} onCancel={onOk} - closable={false} + closable={true} width={700} footer={[ - , ]} @@ -71,9 +84,9 @@ export function MarkdownModal({ - + diff --git a/frontend/javascripts/oxalis/view/right-border-tabs/comment_tab/comment_tab_view.tsx b/frontend/javascripts/oxalis/view/right-border-tabs/comment_tab/comment_tab_view.tsx index 1d8956e7e0b..8e80e0defab 100644 --- a/frontend/javascripts/oxalis/view/right-border-tabs/comment_tab/comment_tab_view.tsx +++ b/frontend/javascripts/oxalis/view/right-border-tabs/comment_tab/comment_tab_view.tsx @@ -240,13 +240,7 @@ class CommentTabView extends React.Component this.nextComment(false); }; - handleChangeInput = ( - evt: React.ChangeEvent, - insertLineBreaks: boolean = false, - ) => { - // @ts-ignore - const commentText = evt.target.value; - + handleChangeInput = (commentText: string, insertLineBreaks: boolean = false) => { if (commentText) { this.props.createComment(insertLineBreaks ? commentText.replace(/\\n/g, "\n") : commentText); } else { @@ -466,7 +460,7 @@ class CommentTabView extends React.Component : messages["tracing.read_only_mode_notification"] } onChange={(evt: React.ChangeEvent) => - this.handleChangeInput(evt, true) + this.handleChangeInput(evt.target.value, true) } onPressEnter={(evt: React.KeyboardEvent) => (evt.target as HTMLElement).blur() diff --git a/frontend/javascripts/oxalis/view/right-border-tabs/dataset_info_tab_view.tsx b/frontend/javascripts/oxalis/view/right-border-tabs/dataset_info_tab_view.tsx index 9e1513fd5f3..eec867cb824 100644 --- a/frontend/javascripts/oxalis/view/right-border-tabs/dataset_info_tab_view.tsx +++ b/frontend/javascripts/oxalis/view/right-border-tabs/dataset_info_tab_view.tsx @@ -3,7 +3,7 @@ import { Tooltip, Typography, Tag } from "antd"; import { SettingOutlined, InfoCircleOutlined, EditOutlined } from "@ant-design/icons"; import { connect } from "react-redux"; import Markdown from "react-remarkable"; -import React, { CSSProperties, ChangeEvent } from "react"; +import React, { CSSProperties } from "react"; import { Link } from "react-router-dom"; import type { APIDataset, APIUser } from "types/api_flow_types"; import { ControlModeEnum } from "oxalis/constants"; @@ -278,10 +278,6 @@ export class DatasetInfoTabView extends React.PureComponent { this.props.setAnnotationName(newName); }; - setAnnotationDescription = (evt: ChangeEvent) => { - this.props.setAnnotationDescription(evt.target.value); - }; - componentDidMount(): void { this.fetchData(); } @@ -500,7 +496,7 @@ export class DatasetInfoTabView extends React.PureComponent { source={this.props.annotation.description} isOpen={this.state.isMarkdownModalOpen} onOk={() => this.setState({ isMarkdownModalOpen: false })} - onChange={this.setAnnotationDescription} + onChange={this.props.setAnnotationDescription} /> );