-
Notifications
You must be signed in to change notification settings - Fork 8.5k
[Discover][FieldFormatters] Migrate html field formatters to react #259286
Copy link
Copy link
Open
Meta
0 / 50 of 5 issues completed
Copy link
Labels
Feature:FieldFormattersMetaTeam:DataDiscoveryDiscover, search (data plugin and KQL), data views, saved searches. For ES|QL, use Team:ES|QL. t//Discover, search (data plugin and KQL), data views, saved searches. For ES|QL, use Team:ES|QL. t//impact:highAddressing this issue will have a high level of impact on the quality/strength of our product.Addressing this issue will have a high level of impact on the quality/strength of our product.loe:x-largeExtra Large Level of EffortExtra Large Level of Effort
Metadata
Metadata
Assignees
Labels
Feature:FieldFormattersMetaTeam:DataDiscoveryDiscover, search (data plugin and KQL), data views, saved searches. For ES|QL, use Team:ES|QL. t//Discover, search (data plugin and KQL), data views, saved searches. For ES|QL, use Team:ES|QL. t//impact:highAddressing this issue will have a high level of impact on the quality/strength of our product.Addressing this issue will have a high level of impact on the quality/strength of our product.loe:x-largeExtra Large Level of EffortExtra Large Level of Effort
Type
Fields
Give feedbackNo fields configured for Meta.
Linking to: https://github.com/elastic/kibana-team/issues/2843
Html field formatters have been around for way too long. It's time to switch to react output for them. Here are the iterative steps which we could follow during this transition as the scope of the changes is quite large.
reactConvertand use it insidehtmlConvertfor backward compatibility which additionally provides better securityBefore: HTML-based Field Formatters (Legacy)
graph TD A[User Data Value] --> B[Field Formatter] B --> C{Content Type?} C -->|text| D[textConvert] C -->|html| E[htmlConvert] D --> F[Plain Text String] E --> G[HTML String with Tags] G --> H[Consumer Component] H --> I["dangerouslySetInnerHTML ⚠️"] I --> J[DOM Rendering] F --> K[Consumer Component] K --> L[Safe Text Rendering] classDef risk fill:#ffcccc,stroke:#ff0000,stroke-width:2px,color:#000000 classDef safe fill:#ccffcc,stroke:#00aa00,stroke-width:2px,color:#000000 class G,I,J risk class F,L safeAfter: React-based Field Formatters with HTML Bridge
graph TD A[User Data Value] --> B[Field Formatter] B --> C{Content Type?} C -->|text| D[textConvert] C -->|html| E[HTML Bridge] C -->|react| F[reactConvert] D --> G[Plain Text String] F --> H[React Elements] F --> I[checkForMissingValueReact] F --> J[getHighlightReact] I --> K[Styled Missing Value Spans] J --> L[Safe Mark Elements] E --> M[Bridge Logic] M --> N{React Output Type?} N -->|ReactElement| O[ReactDOM.renderToStaticMarkup] N -->|String/Number| P[HTML Escape] O --> Q[Safe HTML String] P --> Q H --> R[Consumer Component] R --> S[Direct React Rendering] S --> T[Safe DOM] Q --> U[Legacy Consumer] U --> V["dangerouslySetInnerHTML (Legacy)"] V --> W[DOM Rendering] classDef safe fill:#ccffcc,stroke:#00aa00,stroke-width:2px,color:#000000 classDef bridge fill:#ccccff,stroke:#0066cc,stroke-width:2px,color:#000000 classDef legacy fill:#ffffcc,stroke:#cc8800,stroke-width:2px,color:#000000 class H,S,T,K,L safe class M,E,O,P,Q bridge class U,V,W legacy