Selection Panel: add formatPropertyValue hook and property/layer context to cleanHTML#1601
Conversation
… to cleanHTML for Selection Panel Co-authored-by: jumpinjackie <563860+jumpinjackie@users.noreply.github.com>
formatPropertyValue hook and property context to cleanHTML
|
@copilot The ISelectionPanelCellContext should also include the name of the active selection layer |
Co-authored-by: jumpinjackie <563860+jumpinjackie@users.noreply.github.com>
Done in commit 815ee54. formatPropertyValue: (value, context) => {
if (context.layerName === "Parcels" && /^-?\d+\.\d+$/.test(value)) {
return parseFloat(value).toFixed(3);
}
return value;
}Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
formatPropertyValue hook and property context to cleanHTMLformatPropertyValue hook and property/layer context to cleanHTML
…s-of-double-number
|
@copilot This is working, the only problem is that your example in the PR description is wrong. The Pls fix up all relevant documentation. |
Fixed the PR description. The usage example now correctly places viewer.mount(el, {
layout: "...",
resourceId: "...",
mapguide: {
agentUri: "...",
selectionSettings: {
formatPropertyValue: (value, context) => {
if (context.layerName === "Parcels" && /^-?\d+\.\d+$/.test(value)) {
return parseFloat(value).toFixed(3);
}
return value;
}
}
}
}); |
The Selection Panel had no mechanism to transform plain-text property values before display, making it impossible to limit decimal precision of floating-point numbers like
38.174886687764541.Changes
New
ISelectionPanelCellContextinterface — carriespropertyNameandlayerName(the name of the active selection layer) and is passed to all value customization functions, enabling property-aware and layer-aware formatting decisions.New
formatPropertyValuehook — called for all property values regardless ofallowHtmlValues. Primary solution for the decimal precision use case. Available onISelectedFeatureProps,ISelectionPanelProps, andSelectionOptions(mount option).Context added to
cleanHTML— signature changed from(html: string) => stringto(html: string, context: ISelectionPanelCellContext) => string. Backward compatible — existing functions ignoring the second argument continue to work.layerNameadded toISelectedFeatureProps— the active selection layer name is now passed down to the feature renderer, and included inISelectionPanelCellContext.Security fix —
getHTMLCleaner()default changed from returning an identity function (silently bypassing DOMPurify) toundefined, so DOMPurify is now correctly used when no custom cleaner is configured.Usage
For HTML values,
formatPropertyValueruns first, thencleanHTMLsanitizes the result.Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.