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

showInputBox - initial value is not returned, if user presses enter without making a change #11503

Closed
roblourens opened this issue Sep 3, 2016 · 6 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug verified Verification succeeded

Comments

@roblourens
Copy link
Member

vscode.window.showInputBox({ value: 'test' }).then(text => {
    console.log('result: ' + text);
});

If the user presses enter without typing, '' is returned. If they type anything, the correct value is returned.

OSX, 1.5.0-insider but not 1.4.

@roblourens roblourens added the bug Issue identified by VS Code Team member as probable bug label Sep 3, 2016
@roblourens
Copy link
Member Author

7ba701b?

@riteshatsencha
Copy link

Running into same issue. Version 1.5 on OS X 10.10.3. Default value is not returned if user does not type in the input box. Thank you.

@golf1052
Copy link
Member

Also noticed this as well when working on my extension.
Version 1.5.2
OS: Windows 10 v1607

@riteshatsencha
Copy link

Is this issue fixed? Does "closed" mean it's fixed? I still am experiencing the same issue, where I have to modify the default value before the input is accepted. Any thoughts?

@bpasero
Copy link
Member

bpasero commented Oct 4, 2016

@riteshatsencha fixed for 1.6.0 which will be released end of week.

@vrachels
Copy link

vrachels commented Sep 1, 2017

Per new bug report (#33691). When pressing enter with no input, if there is a validateInput function, if the default value is invalid, then the default value is still passed as an accepted return value.
ie:

const descStr = await vscode.window.showInputBox({
  validateInput: (value: string) => {
    if(!value || value.trim().length === 0) {
      return 'Cannot set empty description';
    }
    return null;
  }
});
if (descStr === undefined || descStr.trim().length == 0) {
  // pressing enter with no other input will still submit the empty string
  Display.showError('Cannot set empty description');
  return;
}

expected behavior would be to run the validator first and respond as per usual valid state (prevent acceptance) (alternately, react as if cancelled)

editing the input box then deleting it again to become invalid works as expected

@vscodebot vscodebot bot locked and limited conversation to collaborators Nov 17, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug verified Verification succeeded
Projects
None yet
Development

No branches or pull requests

6 participants