Skip to content

Commit 9e02afe

Browse files
authored
Embedding Projector: fix bookmark panel (#6294)
* Motivation for features / changes Bookmark panel is currently broken. You can not switch between bookmarks, name bookmarks or delete bookmarks * Technical description of changes This fixes aforementioned bookmark issues. * Screenshots of UI changes * Detailed steps to verify changes work correctly (as executed by you) * Alternate designs / implementations considered
1 parent 8e1a542 commit 9e02afe

File tree

1 file changed

+6
-16
lines changed

1 file changed

+6
-16
lines changed

tensorboard/plugins/projector/vz_projector/vz-projector-bookmark-panel.ts

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ class BookmarkPanel extends LegacyElementMixin(PolymerElement) {
169169
}
170170
/** Handles a radio button click on a saved state. */
171171
_radioButtonHandler(evt: Event) {
172-
const index = this.getParentDataIndex(evt);
172+
const index = this.getBookmarkIndex(evt);
173173
this.loadSavedState(index);
174174
this.setSelectionState(index, true);
175175
}
@@ -190,30 +190,20 @@ class BookmarkPanel extends LegacyElementMixin(PolymerElement) {
190190
this.notifyPath(path, selected);
191191
}
192192
/**
193-
* Crawls up the DOM to find an ancestor with a data-index attribute. This is
194-
* used to match events to their bookmark index.
193+
* Return an event's to their bookmark index.
195194
*/
196-
private getParentDataIndex(evt: Event) {
197-
for (let i = 0; i < (evt as any).path.length; i++) {
198-
let elem = (evt as any).path[i];
199-
if (elem instanceof HTMLElement) {
200-
let dataIndex = elem.getAttribute('data-index');
201-
if (dataIndex != null) {
202-
return +dataIndex;
203-
}
204-
}
205-
}
206-
return -1;
195+
private getBookmarkIndex(evt: any) {
196+
return evt.model.__data.index;
207197
}
208198
/** Handles a clear button click on a bookmark. */
209199
_clearButtonHandler(evt: Event) {
210-
let index = this.getParentDataIndex(evt);
200+
let index = this.getBookmarkIndex(evt);
211201
this.splice('savedStates', index, 1);
212202
this.updateHasStates();
213203
}
214204
/** Handles a label change event on a bookmark. */
215205
_labelChange(evt: Event) {
216-
let index = this.getParentDataIndex(evt);
206+
let index = this.getBookmarkIndex(evt);
217207
this.savedStates[index].label = (evt.target as any).value;
218208
}
219209
/**

0 commit comments

Comments
 (0)