Browse Source

Fixed #831: items losing selection when their type changed.

flowchartTest
jos 9 years ago
parent
commit
7f01183c4d
2 changed files with 8 additions and 1 deletions
  1. +1
    -0
      HISTORY.md
  2. +7
    -1
      lib/timeline/component/ItemSet.js

+ 1
- 0
HISTORY.md View File

@ -27,6 +27,7 @@ http://visjs.org
- Deprecated event `finishedRedraw` as it's redundant.
- Renamed option `animate` to `animation`, and changed it to be either a boolean
or an object `{duration: number, easingFunction: string}`.
- Fixed #831: items losing selection when their type changed.
### Graph2d

+ 7
- 1
lib/timeline/component/ItemSet.js View File

@ -818,11 +818,13 @@ ItemSet.prototype._onUpdate = function(ids) {
var type = me._getType(itemData);
var constructor = ItemSet.types[type];
var selected;
if (item) {
// update item
if (!constructor || !(item instanceof constructor)) {
// item type has changed, delete the item and recreate it
selected = item.selected; // preserve selection of this item
me._removeItem(item);
item = null;
}
@ -837,6 +839,10 @@ ItemSet.prototype._onUpdate = function(ids) {
item = new constructor(itemData, me.conversion, me.options);
item.id = id; // TODO: not so nice setting id afterwards
me._addItem(item);
if (selected) {
this.selection.push(id);
item.select();
}
}
else if (type == 'rangeoverflow') {
// TODO: deprecated since version 2.1.0 (or 3.0.0?). cleanup some day
@ -847,7 +853,7 @@ ItemSet.prototype._onUpdate = function(ids) {
throw new TypeError('Unknown item type "' + type + '"');
}
}
});
}.bind(this));
this._order();
this.stackDirty = true; // force re-stacking of all items next redraw

Loading…
Cancel
Save