-
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
Changes from 6 commits
6591424
5043c9b
54cd63e
69b82eb
3336d89
d53e0b2
2ceb323
1f2bb44
e305eeb
b582603
1f47df2
5d94a47
551af62
13a099a
d5977f5
98eacc9
af12d82
f151102
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 |
---|---|---|
|
@@ -1034,6 +1034,8 @@ export class ColorPicker | |
numberingSystem={this.numberingSystem} | ||
onCalciteInputNumberChange={this.handleChannelChange} | ||
onCalciteInputNumberInput={this.handleChannelInput} | ||
onFocus={this.handleInputFocus} | ||
onInput={this.handleChannelInputChange} | ||
onKeyDown={this.handleKeyDown} | ||
scale={this.scale === "l" ? "m" : "s"} | ||
// workaround to ensure input borders overlap as desired | ||
|
@@ -1055,12 +1057,22 @@ export class ColorPicker | |
// | ||
//-------------------------------------------------------------------------- | ||
|
||
handleChannelInputChange = (event: Event): void => { | ||
const customEvent = event as CustomEvent; | ||
this.handleChannelChange(customEvent); | ||
}; | ||
|
||
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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. I'll create a separate issue for this. |
||
const input = event.currentTarget as HTMLCalciteInputNumberElement; | ||
input.selectText(); | ||
}; | ||
|
||
private showIncompatibleColorWarning(value: ColorValue, format: Format): void { | ||
console.warn( | ||
`ignoring color value (${value}) as it is not compatible with the current format (${format})`, | ||
|
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 toinput
). Applies to the hex-input changes.