diff --git a/src/annotation/index.ts b/src/annotation/index.ts index 2971b6f6e..27cc2d3f1 100644 --- a/src/annotation/index.ts +++ b/src/annotation/index.ts @@ -544,7 +544,7 @@ export function formatAnnotationPropertyValue( export function parseAnnotationPropertyId(obj: unknown) { const s = verifyString(obj); - if (s.match(/^[a-zA-Z0-9_ -]+$/) === null) { + if (s.match(/^[a-z][a-zA-Z0-9_]*$/) === null) { throw new Error(`Invalid property identifier: ${JSON.stringify(obj)}`); } return s; diff --git a/src/layer/annotation/index.ts b/src/layer/annotation/index.ts index 35e5fcea5..2e2d5d3f5 100644 --- a/src/layer/annotation/index.ts +++ b/src/layer/annotation/index.ts @@ -101,7 +101,6 @@ import { VirtualList } from "#src/widget/virtual_list.js"; const POINTS_JSON_KEY = "points"; const ANNOTATIONS_JSON_KEY = "annotations"; -// const TAGS_JSON_KEY = "tags"; const ANNOTATION_PROPERTIES_JSON_KEY = "annotationProperties"; const ANNOTATION_RELATIONSHIPS_JSON_KEY = "annotationRelationships"; const CROSS_SECTION_RENDER_SCALE_JSON_KEY = "crossSectionAnnotationSpacing"; @@ -515,7 +514,7 @@ class TagsTab extends Tab { type: "uint8", tag: value, default: 0, - description: value, + description: undefined, identifier: getUniqueTagPropertyId(localAnnotations), }); } @@ -531,13 +530,14 @@ class TagsTab extends Tab { inputElement.required = true; el.append(inputElement); if (index === listSource.length - 1) { + // add new tag UI el.classList.add("add"); // this is created just to match the width of the tool button const tool = makeToolButton(this, layer.toolBinder, { toolJson: `${TOOL_ID}_${"_invalid"}`, }); el.prepend(tool); - inputElement.placeholder = "enter tag name"; + inputElement.placeholder = "Tag name"; // select input when number of tags increases, this is useful for adding multiple tags in a row if (previousListLength < listSource.length) { setTimeout(() => { @@ -577,7 +577,6 @@ class TagsTab extends Tab { properties.changed.dispatch(); this.layer.manager.root.selectionState.changed.dispatch(); // TODO, this is probably not the best way to handle it }); - const end = document.createElement("div"); const deleteButton = makeDeleteButton({ title: "Delete tag", onClick: (event) => { @@ -590,8 +589,7 @@ class TagsTab extends Tab { }, }); deleteButton.classList.add("neuroglancer-tag-list-entry-delete"); - end.append(deleteButton); - el.append(end); + el.append(deleteButton); } return el; }, @@ -1053,10 +1051,6 @@ export class AnnotationUserLayer extends Base { x[SHADER_CONTROLS_JSON_KEY] = this.annotationDisplayState.shaderControls.toJSON(); Object.assign(x, this.linkedSegmentationLayers.toJSON()); - // if (this.tags.value.length) { - // x[TAGS_JSON_KEY] = this.tags.value.map((x) => x.value); - // console.log("FOO", x[TAGS_JSON_KEY]); - // } return x; } diff --git a/src/layer/index.ts b/src/layer/index.ts index cbf2b493e..3bee68eb3 100644 --- a/src/layer/index.ts +++ b/src/layer/index.ts @@ -208,7 +208,12 @@ export class UserLayer extends RefCounted { const unregister = existingSignal.add(handler); return () => { const res = unregister(); - // TODO delete from map? currently handlers is private + // TODO delete from layerEventListeners if no other handlers attached? currently Signal.handlers is private + /* + if (existingSignal.handlers.length === 0) { + layerEventListeners.delete(type); + } + */ return res; }; }