-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(control): controls display id instead of label #746
Conversation
Controls would display the `id` field a lot except for the like one place where we did properly lookup the label. This adds a new generic way to query for props by name (ignoring value). This retains `id` as a fallback as a bridge way to move to identifying whether that is better or if we should instead just not display anything label-like at all. The latter requires far larger refactoring.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -24,7 +24,7 @@ function testOSCALProfile(parentElementName, renderer) { | |||
jest.setTimeout(6000); | |||
test(`${parentElementName} displays controls`, async () => { | |||
renderer(); | |||
const result = await screen.findByText("ac-1", { | |||
const result = await screen.findByText("AC-1", { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This changes because we now properly use the label which does specify the value in uppercase.
@@ -58,7 +74,7 @@ describe("OSCALCatalogGroup", () => { | |||
fireEvent.click(expand2); | |||
|
|||
const expand3 = screen.getByText( | |||
"CONTROL-ID Access Control Policy and Procedures" | |||
getTextByChildren("control-id Access Control Policy and Procedures") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is now lowercase because we make the text uppercase in CSS instead of by calling toUppercase
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow, so smart!
@@ -35,6 +35,22 @@ const testGroups = [ | |||
}, | |||
]; | |||
|
|||
function getTextByChildren(text) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is necessary because we're now potentially pulling text across multiple <span>
s.
@@ -488,7 +486,7 @@ export function OSCALReplacedProseWithByComponentParameterValue(props) { | |||
<Link underline="hover" href={`#${props.label}`}> | |||
{props.label} | |||
</Link> | |||
</StyledTooltip> | |||
</StyledTooltip>{" "} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This fixes the issue with the label being "squished" up against the actual text. Same for the changes above where {props.label}
and {prose}
are now on the same line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work @kylelaker!
@@ -58,7 +74,7 @@ describe("OSCALCatalogGroup", () => { | |||
fireEvent.click(expand2); | |||
|
|||
const expand3 = screen.getByText( | |||
"CONTROL-ID Access Control Policy and Procedures" | |||
getTextByChildren("control-id Access Control Policy and Procedures") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow, so smart!
Currently, controls are often displayed with their
id
in uppercase instead of using thelabel
property. This means that the display is not necessarily always what a document author may intend (even if it perhaps is close).The label is displayed matching the surrounding content. If the ID is used, it falls back to displaying using the ID (in our standard grey color).
This also fixes an issue where, for prose, the label was squished up against the text without a space.
Screenshots - Test Catalog
Before
After
Screenshots - SP 800-53
Before
After