-
Notifications
You must be signed in to change notification settings - Fork 311
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug: When setting "editable:true" after initialization, items that were added previously are not editable #662
Comments
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Hey, I appreciate the enthusiasm and work investigating the issues but can you please try gathering all your discoveries to a single message? You are spamming maintainers' emails. We love community help! Just take these comments as a thread and not a chat. |
Ah, sorry. Yeah, I don't appreciate mass emails either, I forgot that you'd be subscribed to this |
Okay, I've gotten to the bottom of this @daattali , and I'm not sure if this is a bug, or rather a feature (lmao). OverviewEssentially, at some stage, more granular control (per item) of editability was introduced, & setting: In order to do this, we must explicitly set Reproducible exampleTo modify your given example: Slightly modified version of original reprex<!doctype html>
<html>
<head>
<title>Timeline</title>
<script type="text/javascript" src="https://unpkg.com/vis-timeline@latest/standalone/umd/vis-timeline-graph2d.min.js"></script>
<link href="https://unpkg.com/vis-timeline@latest/styles/vis-timeline-graph2d.min.css" rel="stylesheet" type="text/css" />
<style type="text/css">
#visualization {
width: 600px;
height: 400px;
border: 1px solid lightgray;
}
</style>
</head>
<body>
<div id="visualization"></div>
<script type="text/javascript">
// DOM element where the Timeline will be attached
var container = document.getElementById('visualization');
// Create a DataSet (allows two way data-binding)
var items = new vis.DataSet([
{id: 1, content: 'item 1', start: '2014-04-20'},
{id: 2, content: 'item 2', start: '2014-04-14'},
{id: 3, content: 'item 3', start: '2014-04-18'},
{id: 4, content: 'item 4', start: '2014-04-16', end: '2014-04-19'},
{id: 5, content: 'item 5', start: '2014-04-25'},
{id: 6, content: 'item 6', start: '2014-04-27', type: 'point'}
]);
// Configuration for the Timeline
var options = {};
// Create a Timeline
var timeline = new vis.Timeline(container, items, options);
timeline.setOptions({editable:true});
timeline.setOptions({editable: {overrideItems: true}});
</script>
</body>
</html> Discussion on validity of this behaviourIt's not clear to me whether this needs fixing or not, but I belive if any aspect of this behaviour is buggy, it's that: When
We possibly need to extend it to also propagate to In fact - non-propagation to
Introduced by: b2560d0 Given that passing From investigation (demo'd in the jsfiddle above), it looks like we can set a global Unfortunate that I didn't clock this earlier, I would have saved myself a bit of a rabbithole of binary searching for the "buggy" commit. ConclusionI'd like to hear the thoughts of @daattali & the maintainers ( @yotamberk , sorry for the spam previously - this time it's real) on what the correct behaviour should be w.r.t propagation of I'll submit a PR that enables propagation, & its at the maintainers disgression whether this "fix" is neccessiated. I will say that the difference in behaviour between setting the option @ instantiation time vs afterwards is confounding to users, enough so that regarding it as a bug may very well be appropiate. |
My personal opinion is that if the timeline itself, as a whole, becomes editable, then that implies anything in it, including previous items, should be editable. That's what would make sense to me intuitively, and I'd imagine most people would expect this behaviour. The settings isn't "makeNewItemsEditable", it's just "editable" meaning "whether or not the widget is editable". |
I think that's reasonable, it's weird and confusing to see behaviours so wildly different for something that should feel like the same operation |
First, I'd like to say thank you to all that are participating in this discussion and are taking interest in this project to help improve it! My opinion is as such: |
@yotamberk agreed that if an item explicitly disallows an option, then setting the option globally shouldn't override it. The issue at hand refers only to the case where the entire timeline first has one option, and then receives another option |
And what is the state of the items? Are they defined as editable? EDIT: Ok I see what you mean. I need to check your PR more in depth. |
Default, no explicit definition.
…On Sat., Oct. 3, 2020, 15:15 Yotam Berkowitz, ***@***.***> wrote:
And what is the state of the items? Are they defined as editable?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#662 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAHIQFFJTK26JFPEOC7TSXDSI5Z6XANCNFSM4RGI67XQ>
.
|
I've come back to this, and I'm glad @yotamberk didn't merge my PR because I understand the intended behaviour (/why it isn't happening) better now. The fiddle has been updated https://jsfiddle.net/matthewstrasiotto/432afdpu/ To summarize my findings: The "real" (reflected in DOM) editability property of an item is given by: timeline.ItemSet.items[i].editable There are two independant inputs with varying precedence that determine an timeline.ItemSet.items[i].data.editable
timeline.ItemSet.options.editable Unless the processing of this inheritance is performed by Previously,
vis-timeline/lib/timeline/component/item/Item.js Lines 100 to 103 in ced7bc8
Ie - when updating item data explicitly, or at construction. When we setOptions(), neither method is invoked (no new items are added, and no explicit item data is changed). So why did explicitly setting Description of some duplicated logic, probably intended to help mitigate this bugvis-timeline/lib/timeline/component/item/Item.js Lines 249 to 251 in ced7bc8
Because of this, even though the editable status update was not updated correctly, the item is able to derive it from the inputs to the editable status. Compare this with vis-timeline/lib/timeline/component/item/Item.js Lines 185 to 186 in ced7bc8
Only one Now see vis-timeline/lib/timeline/component/item/Item.js Lines 302 to 308 in ced7bc8
This uses similar duplicated logic to One more noteThe following annotated line means that if you explicitly set an items option via its data attribute (Expecting that option to override that particular global setting), this will work, however it clobbers everything else provided by the global setting for that item. vis-timeline/lib/timeline/component/item/Item.js Lines 548 to 553 in ced7bc8
For example: timeline.ItemSet.items[0].data.editable.remove = true
timeline.setOptions({editable: {updateTime: true}})
//updateTime setting is ignored here, time isn't updatable. This was not a bug, & was actually explicitly tested for, but was slated to change with the major release 5.0.0 . We're a few versions beyond that, & the TODO note is still hanging around. I've updated the behaviour, but perhaps the right thing to do here is to defer this update until major release 8.0.0. It's overdue, but also, still constitutes a breaking change. What are your thoughts @yotamberk ? |
If you initialize a timeline with no options, and then use
setOptions({editable:true})
, any items that were created on initialization are not editable (cannot be moved or deleted). If the timeline is initialized witheditable:true
then all items are editable.Reproducible example, based on the example in the README with only the last line added by me:
This has been previously reported and remained open in both almende/vis#3852 and yotamberk/timeline-plus#99
The text was updated successfully, but these errors were encountered: