File tree Expand file tree Collapse file tree
block-components/typography
components/dynamic-content-control Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -116,11 +116,12 @@ export const Controls = props => {
116116 value = { unescape ( text ) }
117117 onChange = { onChangeContent }
118118 /**
119- * Pass the unescaped Dynamic Content `onChange` function.
119+ * Dynamic Content generates this markup itself. Preserve it because
120+ * HTML validation normalizes string ampersands in its attribute.
120121 *
121122 * @param {string } text Text with dynamic content.
122123 */
123- changeDynamicContent = { onChangeContent }
124+ changeDynamicContent = { text => updateAttribute ( 'text' , text ) }
124125 isDynamic = { true }
125126 />
126127 ) }
Original file line number Diff line number Diff line change @@ -15,7 +15,6 @@ import { QueryLoopContext } from '~stackable/higher-order/with-query-loop-contex
1515 */
1616import { __ } from '@wordpress/i18n'
1717import { useBlockEditContext } from '@wordpress/block-editor'
18- import { escapeAttribute } from '@wordpress/escape-html'
1918import {
2019 Button ,
2120 TextControl ,
@@ -123,10 +122,8 @@ export const useDynamicContentControlProps = props => {
123122
124123 const onChange = ( newValue , editorQueryString , frontendQueryString ) => {
125124 // If `isFormatType` is true, the onChange function will generate a `stackable/dynamic-content` format type.
126- // Custom date formats add query parameters with "&"" character. Escape it so
127- // HTML validation in Typography preserves this as markup, not text.
128125 const willChangeValue = props . isFormatType
129- ? `<span data-stk-dynamic="${ escapeAttribute ( frontendQueryString ) } " contenteditable="false" class="stk-dynamic-content">${ newValue } </span>`
126+ ? `<span data-stk-dynamic="${ frontendQueryString } " contenteditable="false" class="stk-dynamic-content">${ newValue } </span>`
130127 : `!#stk_dynamic/${ frontendQueryString } !#`
131128
132129 props . onChange ( willChangeValue )
You can’t perform that action at this time.
0 commit comments