Repository: wagtail/wagtail

Issue:
Scheduled publishing overlay only opens on settings tab with custom settings_panels (4.1rc1)
### Issue Summary

In the (new) default wagtail setup the settings tab is not visible, but the `settings_panels` are still used for the `CommentPanel` and the `PublishingPanel`.
If you add custom panels to the `settings_panels`, which is a very common thing, the settings tab gets visible, but then, the schedule overlay (when clicking on "Set schedule" in the sidebar) only gets visible, when you navigate to the settings tab.

### Steps to Reproduce

1. Start a new project with `wagtail start myproject`
2. Edit the `home/models.py`:
```python
from django.db import models
from wagtail.admin.panels import FieldPanel
from wagtail.models import Page

class HomePage(Page):
    subtitle = models.CharField(
        max_length=255,
        blank=True,
    )

    settings_panels = Page.settings_panels + [
        FieldPanel("subtitle"),
    ]
```
3. `./manage.py makemigrations && ./manage.py migrate && ./manage.py createsuperuser && ./manage.py runserver`
4. Login to the CMS and edit the home page
5. On any other tab then the settings tab, try to open the schedule overlay. Only when you navigate to the settings tab, you will see it...

-   I have confirmed that this issue can be reproduced as described on a fresh Wagtail project: yes

### Technical details

-   Python version: 3.10
-   Django version: 4.1
-   Wagtail version: 4.1rc1
-   Browser version: Firefox 105



Discussion:
Hi, I would like to work on this issue. Following the steps to reproduce as described.

Hey @Yekasumah 
Are you still working on this issue ?


Resolving patch:
diff --git a/wagtail/admin/panels.py b/wagtail/admin/panels.py
--- a/wagtail/admin/panels.py
+++ b/wagtail/admin/panels.py
@@ -1115,6 +1115,7 @@ def get_context_data(self, parent_context=None):
             context = super().get_context_data(parent_context)
             context["request"] = self.request
             context["instance"] = self.instance
+            context["classname"] = self.classname
             if isinstance(self.instance, Page):
                 context["page"] = self.instance
             return context


Test patch:
diff --git a/wagtail/admin/tests/pages/test_edit_page.py b/wagtail/admin/tests/pages/test_edit_page.py
--- a/wagtail/admin/tests/pages/test_edit_page.py
+++ b/wagtail/admin/tests/pages/test_edit_page.py
@@ -410,6 +410,14 @@ def test_edit_post_scheduled(self):
             allow_extra_attrs=True,
         )
 
+        # Should show the dialog template pointing to the [data-edit-form] selector as the root
+        self.assertTagInHTML(
+            '<div id="schedule-publishing-dialog" class="w-dialog publishing" data-dialog-root-selector="[data-edit-form]">',
+            html,
+            count=1,
+            allow_extra_attrs=True,
+        )
+
         self.assertContains(
             response,
             "This publishing schedule will only take effect after you have published",
@@ -1007,6 +1015,14 @@ def test_edit_post_save_schedule_before_a_scheduled_expire_page(self):
             allow_extra_attrs=True,
         )
 
+        # Should show the dialog template pointing to the [data-edit-form] selector as the root
+        self.assertTagInHTML(
+            '<div id="schedule-publishing-dialog" class="w-dialog publishing" data-dialog-root-selector="[data-edit-form]">',
+            html,
+            count=1,
+            allow_extra_attrs=True,
+        )
+
     def test_edit_post_publish_schedule_before_a_scheduled_expire_page(self):
         # First let's publish a page with *just* an expire_at in the future
         expire_at = timezone.now() + datetime.timedelta(days=20)
diff --git a/wagtail/snippets/tests/test_snippets.py b/wagtail/snippets/tests/test_snippets.py
--- a/wagtail/snippets/tests/test_snippets.py
+++ b/wagtail/snippets/tests/test_snippets.py
@@ -1956,6 +1956,14 @@ def test_edit_post_scheduled(self):
             allow_extra_attrs=True,
         )
 
+        # Should show the dialog template pointing to the [data-edit-form] selector as the root
+        self.assertTagInHTML(
+            '<div id="schedule-publishing-dialog" class="w-dialog publishing" data-dialog-root-selector="[data-edit-form]">',
+            html,
+            count=1,
+            allow_extra_attrs=True,
+        )
+
     def test_edit_scheduled_go_live_before_expiry(self):
         response = self.post(
             post_data={
@@ -2089,6 +2097,14 @@ def test_edit_post_publish_scheduled_unpublished(self):
             allow_extra_attrs=True,
         )
 
+        # Should show the dialog template pointing to the [data-edit-form] selector as the root
+        self.assertTagInHTML(
+            '<div id="schedule-publishing-dialog" class="w-dialog publishing" data-dialog-root-selector="[data-edit-form]">',
+            html,
+            count=1,
+            allow_extra_attrs=True,
+        )
+
     def test_edit_post_publish_now_an_already_scheduled_unpublished(self):
         # First let's publish an object with a go_live_at in the future
         go_live_at = now() + datetime.timedelta(days=1)
@@ -2154,6 +2170,14 @@ def test_edit_post_publish_now_an_already_scheduled_unpublished(self):
             allow_extra_attrs=True,
         )
 
+        # Should show the dialog template pointing to the [data-edit-form] selector as the root
+        self.assertTagInHTML(
+            '<div id="schedule-publishing-dialog" class="w-dialog publishing" data-dialog-root-selector="[data-edit-form]">',
+            html,
+            count=1,
+            allow_extra_attrs=True,
+        )
+
     def test_edit_post_publish_scheduled_published(self):
         self.test_snippet.save_revision().publish()
         self.test_snippet.refresh_from_db()
@@ -2239,6 +2263,14 @@ def test_edit_post_publish_scheduled_published(self):
             allow_extra_attrs=True,
         )
 
+        # Should show the dialog template pointing to the [data-edit-form] selector as the root
+        self.assertTagInHTML(
+            '<div id="schedule-publishing-dialog" class="w-dialog publishing" data-dialog-root-selector="[data-edit-form]">',
+            html,
+            count=1,
+            allow_extra_attrs=True,
+        )
+
     def test_edit_post_publish_now_an_already_scheduled_published(self):
         self.test_snippet.save_revision().publish()
 
@@ -2407,6 +2439,14 @@ def test_edit_post_save_schedule_before_a_scheduled_expire(self):
             allow_extra_attrs=True,
         )
 
+        # Should show the dialog template pointing to the [data-edit-form] selector as the root
+        self.assertTagInHTML(
+            '<div id="schedule-publishing-dialog" class="w-dialog publishing" data-dialog-root-selector="[data-edit-form]">',
+            html,
+            count=1,
+            allow_extra_attrs=True,
+        )
+
     def test_edit_post_publish_schedule_before_a_scheduled_expire(self):
         # First let's publish an object with *just* an expire_at in the future
         expire_at = now() + datetime.timedelta(days=20)
@@ -2505,6 +2545,14 @@ def test_edit_post_publish_schedule_before_a_scheduled_expire(self):
             allow_extra_attrs=True,
         )
 
+        # Should show the dialog template pointing to the [data-edit-form] selector as the root
+        self.assertTagInHTML(
+            '<div id="schedule-publishing-dialog" class="w-dialog publishing" data-dialog-root-selector="[data-edit-form]">',
+            html,
+            count=1,
+            allow_extra_attrs=True,
+        )
+
     def test_edit_post_publish_schedule_after_a_scheduled_expire(self):
         # First let's publish an object with *just* an expire_at in the future
         expire_at = now() + datetime.timedelta(days=20)
@@ -2606,6 +2654,14 @@ def test_edit_post_publish_schedule_after_a_scheduled_expire(self):
             allow_extra_attrs=True,
         )
 
+        # Should show the dialog template pointing to the [data-edit-form] selector as the root
+        self.assertTagInHTML(
+            '<div id="schedule-publishing-dialog" class="w-dialog publishing" data-dialog-root-selector="[data-edit-form]">',
+            html,
+            count=1,
+            allow_extra_attrs=True,
+        )
+
 
 class TestSnippetUnpublish(TestCase, WagtailTestUtils):
     def setUp(self):