Wagtail: TableBlock cell content alignment context menu has returned

Created on 19 Oct 2017  路  3Comments  路  Source: wagtail/wagtail

Issue Summary

The TableBlock Alignment context menu item has returned, following removal in Wagtail 1.6 http://docs.wagtail.io/en/stable/releases/1.6.html#bug-fixes

Might be due to this commit: https://github.com/wagtail/wagtail/commit/6e42a7755ada9ba162e78af6535924449ce3287

Steps to Reproduce

Technical details

  • Python version: 3.4.2
  • Django version: 1.11.4
  • Wagtail version: 1.12.2
  • Browser version: Chrome 64
Streamfield good first issue Bug

All 3 comments

@richbrennan thank you for this issue report we appreciate the detail.

I have reproduced this issue on Wagtail version 1.13 as well.

Cause of Issue

The contextMenu TableBlock.default_table_options is set to True and will always override the js file options.
https://github.com/wagtail/wagtail/blob/master/wagtail/contrib/table_block/blocks.py#L45

These options are parsed in the Javascript file:
https://github.com/wagtail/wagtail/blob/master/wagtail/contrib/table_block/static/table_block/js/table.js#L102

Which causes the contextMenu to be set to True instead of the correct List

    contextMenu: [
        'row_above',
        'row_below',
        '---------',
        'col_left',
        'col_right',
        '---------',
        'remove_row',
        'remove_col',
        '---------',
        'undo',
        'redo'
    ]

Suggested Fix

So we can ensure the integrity of how this option is defined in the documentation.

The table.js file should parse tableOptions so that if it is contextMenu is set to true, use the default contextMenu options defaultOptions.contextMenu, otherwise set contextMenu to false.

Any other thoughts @gasman or @loicteixeira

@lb- Indeed, the JS should do a little bit more work than simply merging the dictionaries here.

However, keep in mind that contextMenu can either be a boolean (e.g. ['undo', 'redo']) or an array so the check will have to be a bit more nuanced than a simple boolean check.

Resolved with #4093

Was this page helpful?
0 / 5 - 0 ratings