Open daattali opened 4 years ago
Copying over a comment from your previous issues:
In version 4.16.1 this bug did not exist.
I'm finding the commit / roughly where this was introduced, so I'm just going to put down some release numbers here to get an idea of when this first occurred:
4.17: d790b3488060457fd8020ffe82b0abb70377b93d
Bug appears present @ 4.18.1 SNAPSHOT https://github.com/almende/vis/blame/4f97bc871c7803f5ab182f761715d0c876570842/package.json
The regression was introduced somewhere between https://github.com/almende/vis/compare/6ac924c4...4f97bc87
https://github.com/almende/vis/compare/bcba4ce48...4f97bc87
The breaking commit is https://github.com/almende/vis/commit/ceb698626acd38f967acfb96886d1e99e571042d
fix(timeline): #2720 Problems with option editable (#2743)
Introduced Item._updateEditStatus()
, significant refactor of edit updates (This is a good one to test)
This is where the regression was originally introduced ( https://github.com/almende/vis/pull/2743 ), however, it seems as though the issue was flagged by ghttps://github.com/almende/vis/issues/2793 & possibly addressed by https://github.com/almende/vis/pull/2796
I'll check out the ref @ 2796 & see if that works
Update https://github.com/almende/vis/commit/3df8107467bdcf88f1c9f55836dc33a12be21f1f is the ref that intends to fix (a) regression added byhttps://github.com/almende/vis/pull/2743 , and perhaps it succeeded, but not in addressing this particular bug
At this state ( https://github.com/almende/vis/commit/3df8107467bdcf88f1c9f55836dc33a12be21f1f ) , Using the example given by Dean above, with the only difference that the source scripts/styles are not external resources, but rather relative)
To fix this, you must explicitly supply timeline.setOptions({editable: {overrideItems: true}});
I will test this on the head of the new repo
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).
Essentially, at some stage, more granular control (per item) of editability was introduced, & setting: timeline.setOptions({editable: true});
does not implicitly override per-item configuration after intantiation time.
In order to do this, we must explicitly set timeline.setOptions({editable: {overrideItems: true}});
, & we see the behaviour we expect.
To modify your given example:
It'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 editable: true
is passed, this option currently propagates to:
editable.updateTime
editable.updateGroup
editable.remove
We possibly need to extend it to also propagate to editable.overrideItems
.
In fact - non-propagation to overrideItems
is explicitly set here:
Introduced by: https://github.com/visjs/vis-timeline/commit/b2560d0b2c7bec8b2b0bd38e919abb60b48b4020
Given that passing {editable: true}
is sort of a sledgehammer approach, & users always have the option to control these options with a more fine-grained approach by passing editable
as an object, I think that letting editable: true
propagate to editable.overrideItems
might be good behaviour.
From investigation (demo'd in the jsfiddle above), it looks like we can set a global overrideItems
that propagates across to everything, and then a granular per-item switch for fine-grained control.
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.
I'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 overrideItems
.
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:
when defining the options as editable: true
it should NOT affect items that are defined individually as not editable.
If one is interested in doing so, you should pass editable: { overrideItems: true }
.
This is the current behavior and I think it should be preserved as such. I agree that the behavior detailed above is a bit complicated and I will look at the PR suggested. If it doesn't affect the current behavior except the initial state, I will agree to accept it.
@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, notifications@github.com 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 https://github.com/visjs/vis-timeline/issues/662#issuecomment-703152211, 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 item.editable
:
timeline.ItemSet.items[i].data.editable
timeline.ItemSet.options.editable
Unless timeline.ItemSet.options.editable.overrideItems = true
, settings are inherited from: timeline.ItemSet.items[i].data.editable
before timeline.ItemSet.options.editable
.
the processing of this inheritance is performed by item._updateEditStatus()
.
Previously, _updateEditStatus()
was called in two places:
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 timeline.setOptions({editable: overrideItems: true})
appear to fix the problem, by giving us our delete buttons back?
The 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.
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 https://github.com/almende/vis/issues/3852 and https://github.com/yotamberk/timeline-plus/issues/99