-
Notifications
You must be signed in to change notification settings - Fork 80
fix(input, input-number): allows numeric characters. #7213
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
Changes from 6 commits
b4cc71c
fbc5210
0eb2956
5cb15ec
ec55735
d51b3ad
f6ef851
8136b4a
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 |
---|---|---|
|
@@ -675,6 +675,11 @@ export class InputNumber | |
return; | ||
} | ||
|
||
// identifies French AZERTY keyboard input | ||
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. Can you generalize this comment? I think this would apply to other keyboard layouts. Bonus points if you use a self-documenting const for this. ⭐ Actually, do we need to care about the Shift key being pressed? Wouldn't we want to process any number from 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. The reason for verifying Shift key here is to make sure the numbers are being returned. In AZERTY keyboard , users need to keep shift key activated for numbers to be printed. Ideally we would like to process any number but as you mentioned there is a custom logic that prevents numberKeys, ArrowKeys and Meta keys with Tab+Shift which results in the bug #6854. I wonder if there will be a case where the Either we need to remove 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.
This is what I'm saying. In AZERTY, when the key combination for a number is pressed, you get a number in
Unless I'm missing something, I think this is the way to go ( |
||
if (numberKeys.includes(event.key) && event.shiftKey) { | ||
return; | ||
} | ||
|
||
numberStringFormatter.numberFormatOptions = { | ||
locale: this.effectiveLocale, | ||
numberingSystem: this.numberingSystem, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1055,20 +1055,12 @@ describe("calcite-input", () => { | |
expect(Number(await element.getProperty("value"))).toBe(195); | ||
}); | ||
|
||
it("disallows typing any letter or number with shift modifier key down", async () => { | ||
it("disallows typing any characters with shift modifier key down", async () => { | ||
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. Would Applies to other test names. |
||
const page = await newE2EPage(); | ||
await page.setContent(html`<calcite-input type="number"></calcite-input>`); | ||
const calciteInput = await page.find("calcite-input"); | ||
const input = await page.find("calcite-input >>> input"); | ||
await calciteInput.callMethod("setFocus"); | ||
|
||
for (let i = 0; i < numberKeys.length; i++) { | ||
await page.keyboard.down("Shift"); | ||
await page.keyboard.press(numberKeys[i] as KeyInput); | ||
await page.keyboard.up("Shift"); | ||
expect(await calciteInput.getProperty("value")).toBeFalsy(); | ||
expect(await input.getProperty("value")).toBeFalsy(); | ||
} | ||
const nonELetterKeys = letterKeys.filter((key) => key !== "e"); | ||
for (let i = 0; i < nonELetterKeys.length; i++) { | ||
await page.keyboard.down("Shift"); | ||
|
@@ -1079,6 +1071,26 @@ describe("calcite-input", () => { | |
} | ||
}); | ||
|
||
// refer to issue here https://github.com/Esri/calcite-components/issues/6854 | ||
it("allows typing numbers with shift modifier key down", async () => { | ||
const page = await newE2EPage(); | ||
await page.setContent(html`<calcite-input type="number"></calcite-input>`); | ||
const calciteInput = await page.find("calcite-input"); | ||
const input = await page.find("calcite-input >>> input"); | ||
await calciteInput.callMethod("setFocus"); | ||
const numberKeysExcludingZero = numberKeys.slice(1); | ||
|
||
let result = ""; | ||
for (let i = 0; i < numberKeysExcludingZero.length; i++) { | ||
await page.keyboard.down("Shift"); | ||
await page.keyboard.press(numberKeysExcludingZero[i] as KeyInput); | ||
result += numberKeysExcludingZero[i]; | ||
await page.keyboard.up("Shift"); | ||
expect(await calciteInput.getProperty("value")).toBe(result); | ||
expect(await input.getProperty("value")).toBe(result); | ||
} | ||
}); | ||
|
||
it("allows shift tabbing", async () => { | ||
const page = await newE2EPage(); | ||
await page.setContent(html` | ||
|
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.
Can you add the issue number in the test name instead? Similar to https://github.com/Esri/calcite-components/blob/14036c1354419222bc5b839af8b68675b17ebf62/packages/calcite-components/src/components/tree/tree.e2e.ts#L962.