projecttacoma / fqm-execution-demo

Apache License 2.0
2 stars 0 forks source link

Added highlighting for reasonDetail #39

Closed sarahmcdougall closed 3 years ago

sarahmcdougall commented 3 years ago

Summary

When accessing the Accordion View results and hovering over the GuidanceResponse reasonDetail, the relevant property that the reasonDetail is referencing is highlighted in the JSON viewer.

New Behavior

All previous behavior is the same, aside from the addition of the highlighted property in the JSON viewer when hovering over the Accordion view results.

Code Changes

A function getSearchString was created in src/components/Results/DetectedIssueResources.tsx to obtain the string in the JSON viewer that we want to highlight. The function takes in a resource and a path, and it traverses through the path’s layers to find the final value that should be highlighted.

A function highlightJSON was created to separate the string we want to highlight from the rest of the resource JSON, and then apply <mark> tags to apply the yellow highlighting. If we cannot find a string to highlight (which is the case with EXM124’s GuidanceResponse for ValueMissing, the stringified JSON is shown in the viewer like before.

These functions are used in handlePopoverOpen() to set the popover content with the highlighted JSON.

Testing Guidance

natjoe4 commented 3 years ago

Code all looks great and functionality works as described :)