Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { Select } from '@sdk/components'
import { InheritanceOverlay } from '../inheritance-overlay/inheritance-overlay'
import { toCssDimension } from '@sdk/utils'
import { type SelectOptionType } from '@sdk/modules/element'
import { renderSanitizedLabel } from '../../utils/select-options'
import { useFieldWidth } from '@Pimcore/modules/element/dynamic-types/definitions/objects/data-related/providers/field-width/use-field-width'

interface MultiSelectEditableProps {
Expand Down Expand Up @@ -54,9 +55,11 @@ export const MultiSelectEditable = ({
<Select
className={ className }
disabled={ inherited }
labelRender={ ({ label }) => renderSanitizedLabel(label) }
mode="multiple"
onChange={ onChange }
optionFilterProp="label"
optionRender={ (option) => renderSanitizedLabel(option.label) }
options={ options }
popupMatchSelectWidth={ false }
style={ containerStyle }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { CreatableSelect } from '@sdk/components'
import { InheritanceOverlay } from '../inheritance-overlay/inheritance-overlay'
import { toCssDimension } from '@sdk/utils'
import { type SelectOptionType } from '@sdk/modules/element'
import { renderSanitizedLabel } from '../../utils/select-options'
import { useFieldWidth } from '@Pimcore/modules/element/dynamic-types/definitions/objects/data-related/providers/field-width/use-field-width'

interface SelectEditableProps {
Expand Down Expand Up @@ -59,8 +60,10 @@ export const SelectEditable = ({
className={ className }
creatable={ editable }
disabled={ inherited }
labelRender={ ({ label }) => renderSanitizedLabel(label) }
onChange={ onChange }
optionFilterProp="label"
optionRender={ (option) => renderSanitizedLabel(option.label) }
options={ options }
popupClassName={ className }
popupMatchSelectWidth={ false }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@ import { SanitizeHtml } from '@Pimcore/components/sanitize-html/sanitize-html'
export type DocumentEditableStoreEntry = [string | number | null, string] | string | number

/**
* Transforms document editable store entries into SelectOptionType array with sanitized HTML labels
* Transforms document editable store entries into SelectOptionType array.
*
* The `label` is returned as a plain string so that antd's built-in search
* (driven by `optionFilterProp="label"`) can match against it. HTML sanitization
* happens at render time via `renderSanitizedLabel`, used by the consuming
* components in their `optionRender` / `labelRender` props.
*/
export const transformDocumentEditableStoreToOptions = (
store?: DocumentEditableStoreEntry[]
Expand All @@ -27,15 +32,25 @@ export const transformDocumentEditableStoreToOptions = (

return {
value: String(value),
label: <SanitizeHtml html={ label } />
label: String(label)
}
} else {
const stringValue = String(item)

return {
value: stringValue,
label: <SanitizeHtml html={ stringValue } />
label: stringValue
}
}
}) ?? []
}

/**
* Renders a label with HTML sanitization. Intended for use in antd's
* `labelRender` / `optionRender` props, so that sanitization happens at the
* moment the label becomes DOM — while `label` itself stays a plain string
* so antd's built-in filter keeps working.
*/
export const renderSanitizedLabel = (label: React.ReactNode): React.JSX.Element => (
<SanitizeHtml html={ typeof label === 'string' ? label : String(label ?? '') } />
)
22 changes: 0 additions & 22 deletions public/build/5536199f-bc79-4594-a107-8c156c4566e8/entrypoints.json

This file was deleted.

33 changes: 0 additions & 33 deletions public/build/5536199f-bc79-4594-a107-8c156c4566e8/manifest.json

This file was deleted.

23 changes: 23 additions & 0 deletions public/build/8f4bcac0-a566-4472-a33e-6bf417a1c282/entrypoints.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading