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

fix: view border styling #2063

Merged
merged 8 commits into from
Jun 14, 2024
Merged

Conversation

ethanalvizo
Copy link
Contributor

@ethanalvizo ethanalvizo commented Jun 7, 2024

Exposed border color style props for view component.

Had to define border color styling using shorthand properties instead to avoid re-rendering bugs. Left comment in code explaining why this approach was taken. Checked to see if border width styling also had similar bugs but weirdly enough it doesn't.

image

@ethanalvizo ethanalvizo requested a review from mofojed June 7, 2024 15:51
@ethanalvizo ethanalvizo self-assigned this Jun 7, 2024
packages/components/src/spectrum/View.tsx Outdated Show resolved Hide resolved
packages/components/src/spectrum/View.tsx Outdated Show resolved Hide resolved
Comment on lines 46 to 47
// Using shorthand to define border styling. Removing a style property during rerender can lead to styling bugs
// ex. changing from borderXColor = blue to borderColor = blue will cause the left and right borders to disappear
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Weird, I can't find the error you mentioned in the React spectrum source code at all. But the error also says "replace the shorthand with separate values", which is the opposite of what you're doing here (you're converting everything to shorthand).
Also, we shouldn't be setting these properties at all if they're not set; leave them undefined, not 'transparent'.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My bad on this one I think I was misusing the useMemo hook earlier. The new way I define borderStyle defines everything into separate values and unset properties are no longer set to transparent

@ethanalvizo
Copy link
Contributor Author

Connected with deephaven/deephaven-plugins#506 so that the border color styling props are applied

@ethanalvizo ethanalvizo requested a review from mofojed June 8, 2024 00:54
Copy link
Member

@mofojed mofojed left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's fine as is, but would be incorrect for RTL languages. We may as well add that support now.

const style = useMemo(() => {
const borderStyle: CSSProperties = {};
if (borderColor !== undefined) {
borderStyle.borderColor = colorValueStyle(borderColor);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice if we could just pass our own conversion function into View... Right now View is using useStyleProps with the viewStyleProps handlers to convert functions: https://github.com/adobe/react-spectrum/blob/bd458c1ed166a5ff1fd93f0c1a397e1540b3d880/packages/%40react-spectrum/view/src/View.tsx#L26C43-L26C57
If we could just pass our own color conversion handler in there somehow, then we wouldn't have to rewrite these props for every color: https://github.com/adobe/react-spectrum/blob/bd458c1ed166a5ff1fd93f0c1a397e1540b3d880/packages/%40react-spectrum/utils/src/styleProps.ts#L263
I'm tempted to file a ticket/PR in the Adobe GitHub repo to add this functionality, since we're ending up having to duplicate a bunch of things here just to handle the borders... but this should be fine for now.

packages/components/src/spectrum/View.tsx Outdated Show resolved Hide resolved
@ethanalvizo ethanalvizo requested a review from mofojed June 14, 2024 04:54
@ethanalvizo ethanalvizo merged commit 6f99e6b into deephaven:main Jun 14, 2024
10 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Jun 14, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants