-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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(KeyComboTag): Better rendering on non-Mac operating systems #7025
Changes from 6 commits
0386e29
f3d75a0
45fa21e
44eb2e7
ebd7728
d5adb40
701f224
672aa41
70ebd7f
d8d658d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
type: fix | ||
fix: | ||
description: The KeyComboTag component no longer renders modifier key icons on non-Mac | ||
operating systems | ||
links: | ||
- https://github.com/palantir/blueprint/pull/7025 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,11 +18,22 @@ import { render, screen } from "@testing-library/react"; | |
import { expect } from "chai"; | ||
import * as React from "react"; | ||
|
||
import { KeyComboTag } from "../../src/components/hotkeys"; | ||
import { KeyComboTagInternal } from "../../src/components/hotkeys/keyComboTag"; | ||
|
||
describe("KeyCombo", () => { | ||
it("renders key combo", () => { | ||
render(<KeyComboTag combo="cmd+C" />); | ||
render(<KeyComboTagInternal combo="cmd+C" platformOverride="Mac" />); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are we using this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agreed its ugly. However, I took a look around and wasn't able to find a good way to mock |
||
expect(screen.getByText("C")).not.to.be.undefined; | ||
}); | ||
|
||
describe("should render minimal key combos on Mac using icons", () => { | ||
render(<KeyComboTagInternal combo="mod+C" minimal={true} platformOverride="Mac" />); | ||
expect(() => screen.getByText("cmd + C", { exact: false })).to.throw; | ||
expect(screen.findAllByAltText("Command key")).not.to.be.undefined; | ||
}); | ||
|
||
it("should render minimal key combos on non-Macs using text", () => { | ||
render(<KeyComboTagInternal combo="mod+C" minimal={true} platformOverride="Win32" />); | ||
expect(screen.getByText("ctrl + C", { exact: false }).innerText).to.equal("ctrl + C"); | ||
}); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
type: fix | ||
fix: | ||
description: The useHotkeys documentation now shows minimal and non-minimal states | ||
for the KeyComboTag component. | ||
links: | ||
- https://github.com/palantir/blueprint/pull/7025 |
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 function is duplicative with another in the codebase, will be looking into refactoring that in a future change.