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

[CSS] "width: 100%" seems to not work inside of Unity #89

Open
kumorikuma opened this issue Mar 31, 2023 · 1 comment
Open

[CSS] "width: 100%" seems to not work inside of Unity #89

kumorikuma opened this issue Mar 31, 2023 · 1 comment
Labels
external bug Bug is caused by an external source, Unity itself or another library

Comments

@kumorikuma
Copy link

kumorikuma commented Mar 31, 2023

I'm seeing an issue in a pretty simple example where setting a % on the width in CSS on a view object doesn't seem to work. In this example, the 'gradient-rule' class should stretch but it doesn't in Unity. It does however, render fine in the browser previewer.

Expected Behavior: a red box is rendered
Actual Behavior: red box is width 0 and not rendered

index.tsx

import { render } from '@reactunity/renderer';
import './index.scss';

function App() {
  return (<view className="black-bar">
    <view className="content">
      <h1 className="title">Title</h1>
      <view className="gradient-rule"></view>
      <p className="message">Message text</p>
    </view>
  </view>);
}

render(<App />);

index.scss

.black-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 250px;
  background-color: black;
  display: flex;
  align-items: center;
  justify-content: center;
}

.content {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  text-align: left;
}

.gradient-rule {
  height: 4px;
  background-color: red;
  // align-self: stretch /* Works */
  width: 100%;  /* Doesn't work */
  // width: 250px;  /* Works */
}
@KurtGokhan KurtGokhan transferred this issue from ReactUnity/reactunity.github.io Mar 31, 2023
@KurtGokhan
Copy link
Member

This seems to happen when the element has percentage width and its parent has auto width. I thought Yoga would handle this case, but apparently it does not. This requires multi-pass calculation so maybe they don't have it for performance reasons. I will open an issue in Yoga and try to fix this.

@KurtGokhan KurtGokhan added the external bug Bug is caused by an external source, Unity itself or another library label Mar 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
external bug Bug is caused by an external source, Unity itself or another library
Projects
None yet
Development

No branches or pull requests

2 participants