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

Missing default attribute values can cause range input display issues or runtime errors #204

Closed
danielghost opened this issue May 20, 2024 · 0 comments · Fixed by #205
Closed
Assignees
Labels

Comments

@danielghost
Copy link
Contributor

danielghost commented May 20, 2024

As there is no default value for _scaleStart and _scaleEnd, the following error will occur if either are omitted from the JSON:

SliderView.js:35 Uncaught TypeError: Cannot read properties of null (reading 'index')
    at SliderView.getIndexFromValue (SliderView.js:35:13)
    at Slider (slider.jsx:49:25)
    at templates.<computed> (reactHelpers.js:17:19)
    at renderWithHooks (react-dom.development.js:15015:20)
    at mountIndeterminateComponent (react-dom.development.js:17841:15)
    at beginWork (react-dom.development.js:19079:18)
    at HTMLUnknownElement.callCallback (react-dom.development.js:3942:16)
    at Object.invokeGuardedCallbackDev (react-dom.development.js:3991:18)
    at invokeGuardedCallback (react-dom.development.js:4053:33)
    at beginWork$1 (react-dom.development.js:23994:9)

For a confidence slider the runtime error isn't immediately shown, but a missing _scaleStart (if using _linkedToId it will attempt to retrieve these values from the linked model) causes the input display to be out of sync with the value (presumably because it defaults to the default 0 min of <input type="range">. If _scaleEnd is missing the scale is displayed incorrectly and the following error occurs when interacting with the slider:

SliderView.js:35 Uncaught TypeError: Cannot read properties of null (reading 'index')
    at ConfidenceSliderView.getIndexFromValue (SliderView.js:35:13)
    at ConfidenceSliderView.onNumberSelected (ConfidenceSliderView.js:34:24)
    at onChange (confidenceSlider.jsx:190:28)
    at HTMLUnknownElement.callCallback (react-dom.development.js:3942:16)
    at Object.invokeGuardedCallbackDev (react-dom.development.js:3991:18)
    at invokeGuardedCallback (react-dom.development.js:4053:33)
    at invokeGuardedCallbackAndCatchFirstError (react-dom.development.js:4067:27)
    at executeDispatch (react-dom.development.js:8273:5)
    at processDispatchQueueItemsInOrder (react-dom.development.js:8305:9)
    at processDispatchQueue (react-dom.development.js:8318:7)

The schema default for _scaleEnd should also be changed from 1.

@danielghost danielghost self-assigned this May 21, 2024
@danielghost danielghost moved this from New to Assigned in adapt_framework: The TODO Board May 21, 2024
danielghost added a commit that referenced this issue May 21, 2024
…d `_scaleStep`. Changed `_scaleEnd` schema default from 1 to 10. (fixes #204).
@danielghost danielghost moved this from Assigned to Needs Reviewing in adapt_framework: The TODO Board May 21, 2024
joe-allen-89 pushed a commit that referenced this issue May 29, 2024
* Fix: added default attribute values for `_scaleStart`, `_scaleEnd` and `_scaleStep`. Changed  `_scaleEnd` schema default from 1 to 10. (fixes #204).

* Removed `_scaleStep` fallbacks as these are no longer needed with a default model value.

* Restrict `_scaleStep` to a positive number, to prevent errors.
@github-project-automation github-project-automation bot moved this from Needs Reviewing to Recently Released in adapt_framework: The TODO Board May 29, 2024
github-actions bot pushed a commit that referenced this issue May 29, 2024
## [4.5.2](v4.5.1...v4.5.2) (2024-05-29)

### Chore

* e2e tests on slider component (Issue/201) (#202) ([4e21470](4e21470)), closes [#202](#202)

### Fix

* missing attribute values causing runtime error (#205) ([a85cdaf](a85cdaf)), closes [#205](#205) [#204](#204)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant