Skip to content
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

Merged
merged 18 commits into from
Jun 20, 2024

Conversation

aPreciado88
Copy link
Contributor

@aPreciado88 aPreciado88 commented Jun 11, 2024

Related Issue: #7057

Summary

Updates color-picker-hex-input to auto apply new color after typing or pasting valid hex value.

@aPreciado88 aPreciado88 requested a review from a team as a code owner June 11, 2024 20:18
@aPreciado88 aPreciado88 added this to the 2024-06-25 - Jun Release milestone Jun 11, 2024
@aPreciado88 aPreciado88 added the pr ready for visual snapshots Adding this label will run visual snapshot testing. label Jun 11, 2024
@aPreciado88 aPreciado88 changed the title fix(color-picker-hex-input): fix color not updating after pasting or typing valid hex value fix(color-picker-hex-input): fix color not auto updating Jun 11, 2024
@aPreciado88 aPreciado88 force-pushed the aPreciado88/7057-apply-entered-hex-value-immediately branch from a65fdb2 to 6591424 Compare June 11, 2024 20:25
@aPreciado88 aPreciado88 added skip visual snapshots Pull requests that do not need visual regression testing. and removed pr ready for visual snapshots Adding this label will run visual snapshot testing. labels Jun 11, 2024
…ciado88/7057-apply-entered-hex-value-immediately
@github-actions github-actions bot added the bug Bug reports for broken functionality. Issues should include a reproduction of the bug. label Jun 11, 2024
Copy link
Member

@jcfranco jcfranco left a 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 => {
Copy link
Member

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?

Copy link
Contributor Author

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}
Copy link
Member

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.

@jcfranco
Copy link
Member

One more thing, committing value on blur or enter is by design, so this should use the feat type. This also matches the request.

@aPreciado88 aPreciado88 changed the title fix(color-picker-hex-input): fix color not auto updating feat(color-picker-hex-input): fix color not auto updating Jun 14, 2024
@aPreciado88 aPreciado88 added enhancement Issues tied to a new feature or request. and removed bug Bug reports for broken functionality. Issues should include a reproduction of the bug. labels Jun 14, 2024
@aPreciado88 aPreciado88 added pr ready for visual snapshots Adding this label will run visual snapshot testing. and removed skip visual snapshots Pull requests that do not need visual regression testing. labels Jun 17, 2024
@aPreciado88 aPreciado88 added skip visual snapshots Pull requests that do not need visual regression testing. and removed pr ready for visual snapshots Adding this label will run visual snapshot testing. labels Jun 17, 2024
…ciado88/7057-apply-entered-hex-value-immediately
Copy link
Member

@jcfranco jcfranco left a 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:

  1. update the test suite to cover this new workflow? I believe current tests use blur and Enter.
  2. revisit the PR title to better match the feature type? fix color not auto updating is still bug-focused.

@aPreciado88 aPreciado88 changed the title feat(color-picker-hex-input): fix color not auto updating feat(color-picker-hex-input): auto apply new color after typing/pasting hex code Jun 18, 2024
@aPreciado88
Copy link
Contributor Author

@jcfranco I updated the test suite and PR title. 🚀

Copy link
Member

@jcfranco jcfranco left a 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");
Copy link
Member

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?

Copy link
Contributor Author

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.

@aPreciado88
Copy link
Contributor Author

@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");
Copy link
Member

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.

Copy link
Contributor Author

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. 🚀

@aPreciado88 aPreciado88 merged commit 8b34583 into dev Jun 20, 2024
9 checks passed
@aPreciado88 aPreciado88 deleted the aPreciado88/7057-apply-entered-hex-value-immediately branch June 20, 2024 23:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Issues tied to a new feature or request. skip visual snapshots Pull requests that do not need visual regression testing.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants