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

EditableText crashes with type='number' with react@16.8.6 #3671

Closed
vadzim opened this issue Jul 24, 2019 · 3 comments · Fixed by #3672
Closed

EditableText crashes with type='number' with react@16.8.6 #3671

vadzim opened this issue Jul 24, 2019 · 3 comments · Fixed by #3672

Comments

@vadzim
Copy link
Contributor

vadzim commented Jul 24, 2019

Environment

  • Package version(s): 3.17.1
  • React version: 16.8.6
  • Browser and OS versions: Chrome 75.0.3770.142 (64-bit), Firefox 68.0.1 (64-bit), Linux

Minimal repro: https://codesandbox.io/s/blueprint-sandbox-jxsv8

Note

This bug is not reproduced with react@16.3.1

Steps to reproduce

  1. Add
<EditableText type="number" defaultValue="12345" />

to the code

  1. Run app, click on that input.

Actual behavior

app crashes here

input.setSelectionRange(this.props.selectAllOnFocus ? 0 : length, length);

in Chrome:

  • empty screen
  • error in console:
Uncaught DOMException: Failed to execute 'setSelectionRange' on 'HTMLInputElement': The input element's type ('number') does not support selection.
    at input (https://nm8s7.csb.app/node_modules/@blueprintjs/core/lib/cjs/components/editable-text/editableText.js:41:27)
    at commitAttachRef (https://nm8s7.csb.app/node_modules/react-dom/cjs/react-dom.development.js:17495:7)

выява

in Firefox:

  • error on screen:
1 of 2 errors on the page
InvalidStateError
An attempt was made to use an object that is not, or is no longer, usable
▼ 16 stack frames were expanded.
input@https://jxsv8.csb.app/node_modules/
blueprintjs/core/lib/cjs/components/editable-text/editableText.js:41:27
commitAttachRef
https://jxsv8.csb.app/node_modules/react-dom/cjs/react-dom.development.js:17495:7

выява

Expected behavior

Component enters editor mode without errors.

@vadzim vadzim changed the title EditableText crashes with type='number' in Chrome with react@16.8.6 EditableText crashes with type='number' with react@16.8.6 Jul 24, 2019
@adidahiya
Copy link
Contributor

What does using an EditableText afford you in this case? Why are you using it instead of an <InputGroup type="number"> or <NumericInput>?

I think we could potentially support type="number" on EditableText, but it would need to be a holistically considered change that fixes this reported crash and also deals with all the multiline-related props which would be unsupported.

@vadzim
Copy link
Contributor Author

vadzim commented Jul 24, 2019

I would suggest that component does not crash the app anyway, may be just ignoring type property.
Though with older react version EditableText works well also with type="number".

I'm using EditableText for numbers in the same way as for general text - basically I need inputs to look like text without any borders and turn editable on clicks. Now I'm using a workaround, I turn EditableText to a controlled component, then handle onChange event and clean the text with regular expression, However this way has some issues, e.g. text cursor jumps to the end of the text when entering not numeric characters.

@vadzim
Copy link
Contributor Author

vadzim commented Jul 24, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants