-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Testing Blueprint table causes error or only 4 rows render #3757
Comments
I had this problem where the table was initially rendered with |
Can you elaborate on this a little? Where did you set the key prob to zero? I've been having similar problems that i can't quite localize. They all seem to involve a number of rows equal to 4. |
I've deleted the code since but it boiled down to this. Changing the key is a way to ensure a stateful component resets its state.
|
Thanks for this. I've had to use this tricky in all of my uses of the Table component. I haven't been able to boil it down to something simple that reproduces the issue. But some features are that: (1) The table only renders exactly 4 rows; (2) it happens after a change in the number of row, or the column width, or column ordering; (3) I believe the problem only started happening after I began using webpack to reduce the footprint of blueprintjs; (4) strategic use of the key deals with the problem. in some cases I'm feeding in a hash that incorporates more than just the number of rows. |
I was using web pack to bundle up libs too. |
It helped me. A request was sent to the server to delete the value, after which a request was sent to the server to obtain a new list of values. After that, a new table error popped up a table error |
I solved that by forcing a const tableRef = useRef()
const onCompleteRender = useCallback(() => {
const lastColumnRegion = Regions.column(10) // Your table last column
tableRef.current.scrollToRegion(lastColumnRegion)
}, [])
<Table
{...tableProps}
ref={tableRef}
onCompleteRender={onCompleteRender}
>
{tableContent}
</Table |
I'll give it a shot, and report back. Thanks. |
Environment
If possible, link to a minimal repro (fork this code sandbox): https://codesandbox.io/s/blueprint-sandbox-3iqf6
Steps to reproduce
Actual behavior
In the sandbox when the test runs you get the error "Failed to execute 'getComputedStyle' on 'Window': parameter 1 is not of type 'Element'."
When running the same example locally in a create-react-app the test runs but fails with "Expected length: 10 Received length: 4". If numRows is set to 4 or lower, the test passes when the correct number of rows are expected, but no more than 4 rows are ever rendered. I also found exactly the same thing for rendering Columns.
Expected behavior
The correct number of rows and columns should be rendered in the test environment.
Possible solution
Don't know - I have already tried a different testing library (react testing library), running the assertion in a callback from the onCompleteRender prop, using different variations of the renderMode prop and setting the row height to minimal size.
The text was updated successfully, but these errors were encountered: