Page MenuHomePhabricator

Tables with template-generated attributes are not editable in VE
Closed, ResolvedPublic

Description

Sometimes VisualEditor refuses to edit a table:

error-2.jpg (477×1 px, 172 KB)

(from here)
It can be daunting for the average editor to figure out what's going on. Ideally, there should be some kind of explanation pointing out exactly which part of the wikitext prevented processing (e.g. in this case it was the {{széptáblázat}} template, used to generate a HTML class for the table). If that's not possible, it should at least explain what's the generic reason for the error (use of transclusion in the structural part of the table wikimarkup, I suppose?).

Event Timeline

This is actually an unintentional change caused by rGVED91a762803e50: ve.dm.ModelRegistry: Disallow unknown types on tag and tag+func matches (T303298). The table has the attribute typeof="mw:ExpandedAttrs" in Parsoid HTML (https://www.mediawiki.org/wiki/Specs/HTML/2.4.0#Generated_attributes_of_HTML_tags), which is unknown to VisualEditor, and which now causes the entire table to not be matched as a ve.dm.MWTableNode, and become uneditable.

I'm not sure if it's really a bug, though. Prior to that change, the table would be editable normally, but changing any of the table properties in the dialog would have no effect (apparently this was also unintentionally changed at some point, see this comment: T65941#2213124).

I suppose a real solution would be to make the table editable (using ve.dm.MWTableNode.static.allowedRdfaTypes = [ 'mw:ExpandedAttrs' ];), then handle that in the table properties dialog to make it read-only in this scenario.

I suppose a real solution would be to make the table editable (using ve.dm.MWTableNode.static.allowedRdfaTypes = [ 'mw:ExpandedAttrs' ];), then handle that in the table properties dialog to make it read-only in this scenario.

That would be ideal, but most of the time people want to change table content, not properties, so if the table was editable but property changes failed silently, that would still be an improvement IMO.

NB we can't easily do the same for table cells, as the generated attribute could be colspan/rowspan, so we would have to prevent any change that added/removed a cell.

Change 890442 had a related patch set uploaded (by Esanders; author: Esanders):

[mediawiki/extensions/VisualEditor@master] Don't allow table attributes to be edited when hasExpandedAttrs

https://gerrit.wikimedia.org/r/890442

matmarex renamed this task from VisualEditor should explain why it refuses to edit a table to VisualEditor sometimes refuses to edit a table with no explanation.Feb 21 2023, 10:03 PM

Change 890442 merged by jenkins-bot:

[mediawiki/extensions/VisualEditor@master] Don't allow table attributes to be edited when hasExpandedAttrs

https://gerrit.wikimedia.org/r/890442

With this change, table contents will be editable again, and only table properties (in the dialog) will not.

With this change, table contents will be editable again, and only table properties (in the dialog) will not.

The "Caption" toggle will still be available as it isn't a table property, but creates a separate node.

EAkinloose subscribed.

✅ table contents are editable
✅ all but the Caption toggle in the table properties dialog is disabled

Screenshot 2023-03-09 at 18.55.07.png (518×1 px, 61 KB)

Screenshot 2023-03-09 at 18.28.41.png (518×1 px, 64 KB)

Esanders renamed this task from VisualEditor sometimes refuses to edit a table with no explanation to Tables with template-generated attributes are not editable in VE.Mar 9 2023, 10:47 PM
matmarex assigned this task to Esanders.

How is this resolved? I just downloaded the 1.38 version and copied it over to my wiki. I'm getting the exact same issue I did before.

image.png (725×1 px, 295 KB)

The patch was not backported to 1.38, it's only included in the upcoming 1.40 release. In general we don't backport VisualEditor patches to the release branches unless someone specifically asks for it and the patch is easy to apply. I think I can backport this one.

Change 905683 had a related patch set uploaded (by Bartosz Dziewoński; author: Esanders):

[mediawiki/extensions/VisualEditor@REL1_38] Don't allow table attributes to be edited when hasExpandedAttrs

https://gerrit.wikimedia.org/r/905683

Change 905684 had a related patch set uploaded (by Bartosz Dziewoński; author: Esanders):

[mediawiki/extensions/VisualEditor@REL1_39] Don't allow table attributes to be edited when hasExpandedAttrs

https://gerrit.wikimedia.org/r/905684

Change 905683 merged by jenkins-bot:

[mediawiki/extensions/VisualEditor@REL1_38] Don't allow table attributes to be edited when hasExpandedAttrs

https://gerrit.wikimedia.org/r/905683

Change 905684 merged by jenkins-bot:

[mediawiki/extensions/VisualEditor@REL1_39] Don't allow table attributes to be edited when hasExpandedAttrs

https://gerrit.wikimedia.org/r/905684

The patch was not backported to 1.38, it's only included in the upcoming 1.40 release. In general we don't backport VisualEditor patches to the release branches unless someone specifically asks for it and the patch is easy to apply. I think I can backport this one.

That would be appreciated. I'll keep an eye out for updates. Thank you for your response and consideration.

The Gerrit changes above were 1.38 and 1.39 backports. If you download now from https://www.mediawiki.org/wiki/Special:ExtensionDistributor/VisualEditor or from Git, you should get the new version.