-
Notifications
You must be signed in to change notification settings - Fork 73
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
Bug: programmatically set size
results in different flexGrow
#147
Comments
@leefsmp Sorry, did you have a chance to take a look at this issue? |
I don't have a suggestion from top of my head sorry. Do you have a codepen/sandbox that I could test quickly? |
@leefsmp I will try to create a minimal repro in a few days! |
@leefsmp Here's a small repro - https://codesandbox.io/s/wizardly-morse-47b2o Screen.Recording.2021-09-23.at.9.55.39.AM.mov |
@leefsmp did you have any chance looking at this issue? |
I will try to look at it this week ... |
I found this is a problem with ReflexContainer adjustFlex, for some reason the flex adjustment is different every time Workaround: I set flex=1 for the visible component and flex=0 for the initially invisible sidebar. |
@mastercoms thanks! I have tested it out and it does fix my problem |
I have the same issue.
So if the current size is very small, the error tends to be large. I modified ReflexElement.js and ReflexContainer.js to not do relative calculations if prop.size changes. The specific changes are as follows. ReflexElement.js @@ -160,6 +160,7 @@
/*#__PURE__*/
_regenerator.default.mark(function _callee(prevProps, prevState, snapshot) {
var directions, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, direction;
+ var _isSetPropSize;
return _regenerator.default.wrap(function _callee$(_context) {
while (1) {
@@ -167,7 +168,10 @@
case 0:
if (!(prevState.size !== this.state.size)) {
_context.next = 28;
+ _isSetPropSize = false;
break;
+ } else {
+ _isSetPropSize = true;
}
directions = toArray(this.props.direction);
@@ -188,7 +192,8 @@
return this.props.events.emit('element.size', {
index: this.props.index,
size: this.props.size,
- direction: direction
+ direction: direction,
+ isSetPropSize: _isSetPropSize
});
case 11: ReflexContainer.js @@ -150,7 +150,7 @@
var splitterIdx = idx + dir;
var availableOffset = _this.computeAvailableOffset(splitterIdx, dir * offset);
-
+ _this.state.isSetPropSize = data.isSetPropSize;
_this.elements = null;
if (availableOffset) {
@@ -168,6 +168,7 @@
// TODO handle exception ...
console.log(ex);
}
+ delete _this.state.isSetPropSize;
});
});
_this.events = new _ReflexEvents.default();
@@ -503,7 +504,7 @@
var size = this.getSize(element);
var idx = element.props.index;
var newSize = Math.max(size + offset, 0);
- var currentFlex = this.state.flexData[idx].flex;
+ var currentFlex = this.state.isSetPropSize ? 0 : this.state.flexData[idx].flex;
var newFlex = currentFlex > 0 ? currentFlex * newSize / size : this.computePixelFlex() * newSize;
this.state.flexData[idx].flex = !isFinite(newFlex) || isNaN(newFlex) ? 0 : newFlex;
} ///////////////////////////////////////////////////////// |
could you submit a PR with modified code from the source in |
sorry at this link #147 (comment) , I can not fix it, by <ReflexElement flex={0} size={size} direction={1}>
<div className="App__side"></div>
</ReflexElement>
<ReflexSplitter />
<ReflexElement flex={1} >
<div className="App__panel"></div>
</ReflexElement>
</ReflexContainer> May I have a more complete code? please. @akphi @mastercoms |
Hi,
I programmatically set the size for a panel and have a button to toggle minimizing it. What I see is the size of the panel changes when I toggle the panel. See the videos below:
In this video, you can see I
console.log
out the size and it stays the same at300
size.stay.the.same.mov
In this video, I repeat the same experiment, but observe the
flex
instyle
, it changesflex.changes.mov
The text was updated successfully, but these errors were encountered: