Paragraph whitespace stripping in bard field
Bug description
After upgrading to Statamic 5, I’ve encountered an issue where the Bard field is stripping whitespace in certain situations. Specifically, when using bold text or hyperlinks within a paragraph, the spaces before and after the formatted text are removed, causing words to run together.
Bard field before saving:
Html source before saving:
Bard field after saving:
Html source after saving:
How to reproduce
- Create or edit an entry with a Bard field.
- Type a paragraph of text.
- Within the paragraph, select a word or phrase in the middle and apply bold formatting or insert a link.
- Save the entry.
- View the published content or revisit the editor.
Logs
No response
Environment
Environment
Application Name: Statamic
Laravel Version: 11.21.0
PHP Version: 8.3.11
Composer Version: 2.7.7
Environment: local
Debug Mode: ENABLED
URL: --
Maintenance Mode: OFF
Timezone: UTC
Locale: en
Cache
Config: NOT CACHED
Events: NOT CACHED
Routes: NOT CACHED
Views: CACHED
Drivers
Broadcasting: log
Cache: file
Database: mysql
Logs: stack / single
Mail: smtp
Queue: redis
Session: redis
Sentry
Enabled: MISSING DSN
Environment: local
Laravel SDK Version: 4.8.0
PHP SDK Version: 4.9.0
Release: NOT SET
Sample Rate Errors: 100%
Sample Rate Performance Monitoring: NOT SET
Sample Rate Profiling: NOT SET
Send Default PII: DISABLED
Statamic
Addons: 2
Sites: 4 (Dutch, English, German, French)
Stache Watcher: Enabled
Static Caching: full
Version: 5.26.0 PRO
Statamic Addons
webographen/statamic-widget-continue-editing: 1.3.2
withcandour/aardvark-seo: 5.0.0
Installation
Fresh statamic/statamic site via CLI
Additional details
I use sets in my bard field. The bard field does not Save as HTML.
Is this happening on the frontend too, or just when you view the source HTML in the Bard editor?
Is this happening on the frontend too, or just when you view the source HTML in the Bard editor?
I'm using the Rest API. And there the rendered html in the json response is also missing whitespace.
After the V5 upgrade when I save a page with Bard fields, without making any content changes, it results in the whitespace being stripped. I get this change in the markdown/yaml content file of the page:
I'm experiencing the exact same issue. Has anyone found a solution?
Please provide a repo with this problem reproduced.
Fixed by #11127