You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug:
When deleting a split area, the following warning appears in the console:
as-split: Percent areas must total 100%
After reviewing my implementation, I confirmed that the area sizes are set correctly.
In my use case, I always have at least 1 and at most 2 split areas at any given time.
When starting with one area or adding a second area, everything works as expected, and no warnings appear.
However, when deleting one of the areas, the warning is triggered—even though the remaining area is configured correctly.
Or, use a simple utility function to deal with this:
/** * utility function to read a signal and return undefined if the signal is not set yet. * This is useful to avoid the NG0950 error when reading a signal before it is set. * @param data * @returns */exportconstearlyReadToUndefined=<T>(data: Signal<T>): T|undefined=>{try{returndata();}catch(err){conste=errasError;if(e?.message?.startsWith('NG0950')){// NG0950: Cannot read from a signal before it is set// this is a known error, so we can just return undefined// https://angular.io/api/core/NG0950returnundefined;}throwe;// rethrow, because we don't know what else to do}};
However, that means you need to handle the undefined value in the function that uses that input. In some cases, the afterRenderEffect is easier to deal with. But it is an effect, and should be avoided unless there is no other solution.
@SanderElias this case is a bit different from the linked issue.
The current validation warning effect has a nested signal access - first the areas content children and then the size of each area.
The problem is that content children emits as soon as it can - before the inputs settled. That means when removing we have one area with size 50 instead of size 100 and sometime later we get another effect run with the size 100. At this point the warning has already been logged.
Concerning what you wrote - the size isn't a required input so the error won't be thrown and there is already an effect for the validations warning logging.
Activity
Harpush commentedon May 27, 2025
Most likely related to angular/angular#59067.
I will try to change the effect to afterRenderEffect and see if it helps
Harpush commentedon May 27, 2025
@Jefiozie @SanderElias Three options here:
afterRenderEffectwhich will postpone the check and wait for full renderisInitsignal like mentioned here (Signal Queries are populated before the input have been set on the components angular/angular#59067 (comment))What do you think?
SanderElias commentedon May 28, 2025
@Harpush
Or, use a simple utility function to deal with this:
However, that means you need to handle the
undefinedvalue in the function that uses that input. In some cases, theafterRenderEffectis easier to deal with. But it is an effect, and should be avoided unless there is no other solution.Harpush commentedon May 28, 2025
@SanderElias this case is a bit different from the linked issue.
The current validation warning effect has a nested signal access - first the areas content children and then the size of each area.
The problem is that content children emits as soon as it can - before the inputs settled. That means when removing we have one area with size 50 instead of size 100 and sometime later we get another effect run with the size 100. At this point the warning has already been logged.
Concerning what you wrote - the size isn't a required input so the error won't be thrown and there is already an effect for the validations warning logging.