-
Notifications
You must be signed in to change notification settings - Fork 80
feat(color-picker): replaces thumb focus outline to rounded #7378
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
Merged
anveshmekala
merged 27 commits into
main
from
anveshmekala/4633-color-picker-fix-focus-outline
Aug 1, 2023
Merged
Changes from 4 commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
29fa91d
feat(color-picker): replaces thumb focus outline to rounded
anveshmekala 6cd2fff
use integer values for width and height
anveshmekala d63ba1b
fix test errors
anveshmekala 6aefbc4
add listener for pointerdown event from thumb
anveshmekala 4fe5813
remove console.log statements
anveshmekala 238bfea
refactor
anveshmekala 7131ed9
replace css with tailwind util classes
anveshmekala 8ae809d
add spec test
anveshmekala f66d93d
cleanup
anveshmekala ce98213
Merge branch 'main' into anveshmekala/4633-color-picker-fix-focus-out…
anveshmekala 2af2d33
add more tests and feedback changes
anveshmekala 46cd9f6
refactor
anveshmekala 4610739
rename
anveshmekala 9ea0443
remove new lines
anveshmekala 3b98bc1
more cleanup
anveshmekala cb33490
disable tab container
anveshmekala 57e0d3c
revert tab focus changes
anveshmekala 355c0ae
Merge branch 'main' into anveshmekala/4633-color-picker-fix-focus-out…
anveshmekala 8ce2e6d
remove empty new lines
anveshmekala 858fafa
change test util method name
anveshmekala 3c98108
add focus screenshot test
anveshmekala 3d585ff
remove pointerDown handler for scope node
anveshmekala d1bc943
update css
anveshmekala 193c54d
feedback changes
anveshmekala 51c728c
change outline offset
anveshmekala 17102cd
tidy up
anveshmekala 6488636
increase delay for focus test
anveshmekala File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -539,6 +539,11 @@ export class ColorPicker | |
context: this.colorFieldRenderingContext, | ||
bounds: this.colorFieldRenderingContext.canvas.getBoundingClientRect(), | ||
}; | ||
|
||
if (event.target === this.colorFieldScopeNode) { | ||
return; | ||
} | ||
|
||
this.captureColorFieldColor(offsetX, offsetY); | ||
this.colorFieldScopeNode.focus(); | ||
}; | ||
|
@@ -557,6 +562,9 @@ export class ColorPicker | |
context: this.hueSliderRenderingContext, | ||
bounds: this.hueSliderRenderingContext.canvas.getBoundingClientRect(), | ||
}; | ||
if (event.target === this.hueScopeNode) { | ||
return; | ||
} | ||
this.captureHueSliderColor(offsetX); | ||
anveshmekala marked this conversation as resolved.
Show resolved
Hide resolved
|
||
this.hueScopeNode.focus(); | ||
}; | ||
|
@@ -580,6 +588,7 @@ export class ColorPicker | |
}; | ||
|
||
private globalPointerUpHandler = (event: PointerEvent): void => { | ||
console.log("pointer up"); | ||
anveshmekala marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if (!isPrimaryPointerButton(event)) { | ||
return; | ||
} | ||
|
@@ -597,6 +606,7 @@ export class ColorPicker | |
const { activeCanvasInfo, el } = this; | ||
|
||
if (!el.isConnected || !activeCanvasInfo) { | ||
console.log("move handler"); | ||
anveshmekala marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return; | ||
} | ||
|
||
|
@@ -769,8 +779,12 @@ export class ColorPicker | |
aria-valuenow={(vertical ? color?.saturationv() : color?.value()) || "0"} | ||
class={{ [CSS.scope]: true, [CSS.colorFieldScope]: true }} | ||
onKeyDown={this.handleColorFieldScopeKeyDown} | ||
onPointerDown={this.handleColorFieldPointerDown} | ||
role="slider" | ||
style={{ top: `${colorFieldScopeTop || 0}px`, left: `${colorFieldScopeLeft || 0}px` }} | ||
style={{ | ||
top: `${colorFieldScopeTop - DIMENSIONS.scopeNode / 2 || 0}px`, | ||
left: `${colorFieldScopeLeft - DIMENSIONS.scopeNode / 2 || 0}px`, | ||
}} | ||
tabindex="0" | ||
// eslint-disable-next-line react/jsx-sort-props | ||
ref={this.storeColorFieldScope} | ||
|
@@ -793,8 +807,12 @@ export class ColorPicker | |
aria-valuenow={color?.round().hue() || DEFAULT_COLOR.round().hue()} | ||
class={{ [CSS.scope]: true, [CSS.hueScope]: true }} | ||
onKeyDown={this.handleHueScopeKeyDown} | ||
onPointerDown={this.handleHueSliderPointerDown} | ||
role="slider" | ||
style={{ top: `${hueTop}px`, left: `${hueLeft}px` }} | ||
style={{ | ||
top: `${hueTop - DIMENSIONS.scopeNode / 2}px`, | ||
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. since a few places are dividing a value by the scopeNode and converting to px maybe convert that into a function for reuse. |
||
left: `${hueLeft - DIMENSIONS.scopeNode / 2}px`, | ||
}} | ||
tabindex="0" | ||
// eslint-disable-next-line react/jsx-sort-props | ||
ref={this.storeHueScope} | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -93,4 +93,5 @@ export const DIMENSIONS = { | |
radius: 10, | ||
}, | ||
}, | ||
scopeNode: 1, | ||
}; |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
One more thing I noticed. The design spec seems to have a 2px space between the thumb and the focus outline. The spacing in the PR screenshot looks larger than that. Maybe adjusting this to 14px can help better match that.
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.
if we increase the spacing from 12px to 14px it will increase the gap between the thumb and outline.
Thoughts @ashetland
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.
Adding @macandcheese.
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.
If I’m following, I agree it should be a 2px gap to align with other “outset focus” styles.