wagtail / wagtail-localize

Translation plugin for Wagtail CMS
https://wagtail-localize.org/
Other
216 stars 83 forks source link

PageChooser not working in translatable snippet #806

Open sjoerdzzid opened 3 weeks ago

sjoerdzzid commented 3 weeks ago

Python==3.11.5 Django==5.0.6 wagtail==6.1.2 wagtail-localize==1.9

The PageChooser is not working in the translated snippet. Clicking the "choose page" button will result in: TypeError: Cannot read properties of undefined (reading 'pageChooser')

My menu consists of a StreamField with a PageChooserBlock

from wagtail import blocks
class MenuItemBlock(blocks.StructBlock):
    title = blocks.CharBlock(
        required=False, max_length=50, help_text=_("The item title")
    )
    link_page = blocks.PageChooserBlock(
        required=False,
        help_text=_(
            "Choose an existing page if selecting an internal link (overrides URL)"
        ),
    )
    link_url = blocks.URLBlock(
        required=False,
        max_length=500,
        help_text=_("e.g. /about/ or https://example.com/"),
    )
....

The editor interface looks like this: image

Seems like a small issue, but I don't know where to start fixing the .js ...

zerolab commented 3 weeks ago

I think this is related to https://github.com/wagtail/wagtail/pull/11620 The fix is to update https://github.com/wagtail/wagtail-localize/blob/main/wagtail_localize/static_src/editor/components/TranslationEditor/segments.tsx#L650 (as well as https://github.com/wagtail/wagtail-localize/blob/main/wagtail_localize/static_src/editor/components/TranslationEditor/segments.tsx#L681, https://github.com/wagtail/wagtail-localize/blob/main/wagtail_localize/static_src/editor/components/TranslationEditor/segments.tsx#L712) to follow a potentially similar bit of logic as the snippet chooser fix in https://github.com/wagtail/wagtail-localize/pull/795/commits/513a34c8df97802e238ed90c01b1c76008e2d9cc

I should have a bit of time tomorrow to look into this