fix(uiGrid): Wait for grid to get dimensions before rendering #3238
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.
This is a fix for #2700 and a few other issues.
The problem here is that for determining the grid width, gridUtil is detecting that when the grid is initialized, it has an offsetWidth of 0, so it creates a "fake" (cloned) element that it attaches to the document with visibility: hidden in order to measure it.
This causes a problem because with width: 100% when attached to the document body the grid will just fill up the whole space. THEN when the real grid is in the modal it takes up way more space than it should.
This change makes the grid wait up to 2 seconds for the element to have a width > 0 before it initializes the dimensions.
Note that this change also has a breaking change, which is that gridUtil can no longer try to get the width of hidden elements, which is the same as jQuery. Hidden elements really don't have any dimension.