Skip to content

Commit 098b437

Browse files
authored
Add docs for enabling user bar and accessibility checker (#73)
1 parent 8510499 commit 098b437

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

README.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ Then configure the preview client URL using the `CLIENT_URLS` option in the `WAG
5151
WAGTAIL_HEADLESS_PREVIEW = {
5252
"CLIENT_URLS": {}, # defaults to an empty dict. You must at the very least define the default client URL.
5353
"SERVE_BASE_URL": None, # can be used for HeadlessServeMixin
54-
"REDIRECT_ON_PREVIEW": False, # set to True to redirect to the preview instead of using the Wagtail default mechanism
54+
"REDIRECT_ON_PREVIEW": False, # set to True to redirect to the client URL instead of using an iframe
5555
"ENFORCE_TRAILING_SLASH": True, # set to False in order to disable the trailing slash enforcement
5656
}
5757
```
@@ -126,6 +126,24 @@ WAGTAIL_HEADLESS_PREVIEW = {
126126
}
127127
```
128128

129+
### Redirect vs. iframe
130+
131+
By default, the preview will render an iframe with the front-end URL. This means that the live preview panel will be displayed using an iframe nested within Wagtail's default preview iframe. Prior to Wagtail 7.1, this was necessary if the frontend is hosted on a separate domain, as the preview panel did not properly handle cross-origin iframes.
132+
133+
If you are using Wagtail 7.1+, it is highly recommended to use a redirect to the frontend URL instead of a nested iframe, regardless whether the frontend is hosted on the same domain or not. This allows Wagtail to enable scroll restoration and other integrations within the page editor. This can be enabled by setting `REDIRECT_ON_PREVIEW` to `True`:
134+
135+
```python
136+
# settings.py
137+
WAGTAIL_HEADLESS_PREVIEW = {
138+
# ...
139+
"REDIRECT_ON_PREVIEW": True,
140+
}
141+
```
142+
143+
### User bar and accessibility checker
144+
145+
If the Wagtail userbar is loaded in the front-end, Wagtail's page editor can restore the scroll position when the preview is updated, as well as enable other integrations such as the accessibility checker and content metrics. See Wagtail's documentation on enabling [the user bar](https://docs.wagtail.org/en/latest/advanced_topics/headless.html#headless-user-bar) and [the accessibility checker](https://docs.wagtail.org/en/latest/advanced_topics/headless.html#headless-accessibility-checker) on headless setups for more information. This requires Wagtail 7.1+ and the `REDIRECT_ON_PREVIEW` setting set to `True`.
146+
129147
## Usage
130148

131149
To enable preview as well as wire in the "View live" button in the Wagtail UI, add the `HeadlessMixin`

0 commit comments

Comments
 (0)