-
Notifications
You must be signed in to change notification settings - Fork 77
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
feat(color-picker-hex-input): auto apply new color after typing/pasting hex code #9561
feat(color-picker-hex-input): auto apply new color after typing/pasting hex code #9561
Conversation
a65fdb2
to
6591424
Compare
…ciado88/7057-apply-entered-hex-value-immediately
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.
Looking good, @aPreciado88! 😎
handleKeyDown(event: KeyboardEvent): void { | ||
if (event.key === "Enter") { | ||
event.preventDefault(); | ||
} | ||
} | ||
|
||
handleInputFocus = (event: Event): void => { |
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.
Selecting text is a great enhancement, but it does seem unrelated to committing on paste/input. Could we submit this separately?
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.
I'll create a separate issue for this.
@@ -1034,6 +1034,8 @@ export class ColorPicker | |||
numberingSystem={this.numberingSystem} | |||
onCalciteInputNumberChange={this.handleChannelChange} | |||
onCalciteInputNumberInput={this.handleChannelInput} | |||
onFocus={this.handleInputFocus} | |||
onInput={this.handleChannelInputChange} |
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.
For consistency, can you use the calcite-specific events? Also, the event name doesn't match the event (e.g., named after the change
event, but it's listening to input
). Applies to the hex-input changes.
One more thing, committing value on blur or enter is by design, so this should use the |
…ciado88/7057-apply-entered-hex-value-immediately
…ciado88/7057-apply-entered-hex-value-immediately
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.
Awesome! Two more things and this should be good to merge, can you:
- update the test suite to cover this new workflow? I believe current tests use
blur
andEnter
. - revisit the PR title to better match the feature type?
fix color not auto updating
is still bug-focused.
…ciado88/7057-apply-entered-hex-value-immediately
@jcfranco I updated the test suite and PR title. 🚀 |
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.
🎨🎨🎨🎨🎨🎨🎨🎨🎨🎨🎨🎨🎨🎨🎨🎨🎨🎨🎨🎨🎨🎨🎨🎨🎨🎨🎨🎨🎨🎨🎨🎨🎨🎨🎨🎨🎨🎨🎨🎨
🎨⌨️⌨️⌨️⌨️🎨⌨️🎨🎨🎨🎨🎨⌨️🎨⌨️⌨️⌨️⌨️🎨🎨⌨️⌨️⌨️🎨🎨⌨️⌨️🎨🎨⌨️🎨🎨🎨⌨️🎨⌨️⌨️⌨️⌨️🎨
🎨⌨️🎨🎨⌨️🎨⌨️🎨🎨🎨🎨🎨⌨️🎨⌨️🎨🎨🎨🎨⌨️🎨🎨🎨🎨⌨️🎨🎨⌨️🎨⌨️⌨️🎨⌨️⌨️🎨⌨️🎨🎨🎨🎨
🎨⌨️⌨️⌨️⌨️🎨⌨️🎨🎨⌨️🎨🎨⌨️🎨⌨️⌨️⌨️🎨🎨🎨⌨️⌨️🎨🎨⌨️🎨🎨⌨️🎨⌨️🎨⌨️🎨⌨️🎨⌨️⌨️⌨️🎨🎨
🎨⌨️🎨🎨⌨️🎨⌨️🎨⌨️🎨⌨️🎨⌨️🎨⌨️🎨🎨🎨🎨🎨🎨🎨⌨️🎨⌨️🎨🎨⌨️🎨⌨️🎨🎨🎨⌨️🎨⌨️🎨🎨🎨🎨
🎨⌨️🎨🎨⌨️🎨🎨⌨️🎨🎨🎨⌨️🎨🎨⌨️⌨️⌨️⌨️🎨⌨️⌨️⌨️🎨🎨🎨⌨️⌨️🎨🎨⌨️🎨🎨🎨⌨️🎨⌨️⌨️⌨️⌨️🎨
🎨🎨🎨🎨🎨🎨🎨🎨🎨🎨🎨🎨🎨🎨🎨🎨🎨🎨🎨🎨🎨🎨🎨🎨🎨🎨🎨🎨🎨🎨🎨🎨🎨🎨🎨🎨🎨🎨🎨🎨
Testing paste
isn't possible due to Puppeteer limitations, right?
@@ -348,6 +348,14 @@ describe("calcite-color-picker-hex-input", () => { | |||
await assertTabAndEnterBehavior("", startingHex); | |||
}); | |||
|
|||
it("commits hex chars when typing", async () => { | |||
await selectText(input); | |||
await page.keyboard.type("abcdef"); |
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.
Since committing on paste/input only works for longhand hex, can you assert on "abc" not changing the value, then assert the value changed once "def" is typed?
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.
I added assertion to only commit longhand hex values.
@jcfranco I tried to include a test for the copy-paste scenario. But it looks like the puppeteer limitations are still present. |
await page.waitForChanges(); | ||
|
||
// asserting that shorthand hex won't be committed | ||
expect(await input.getProperty("value")).toBe("#b33f33"); |
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.
You could use startingHex
here instead of the actual hex value.
Also, I think the comments can be removed since the updated test name and assertions make it clear what the test entails.
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.
I updated the test to use startingHex
and removed the comments. 🚀
…ciado88/7057-apply-entered-hex-value-immediately
Related Issue: #7057
Summary
Updates
color-picker-hex-input
to auto apply new color after typing or pasting valid hex value.