question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

The modal insert dialog is hidden although onAddRow returns a string

See original GitHub issue

According to handleSaveBtnClick in Toolbar.js a value/object that is returned by the function assigned to onAddRow in the BootstrapTable options should lead to a notice and the modal not being hidden. This does’t work. The reason is that handleAddRow in BootstrapTable.js does call onAddRow without returning the result. It should look like this:

handleAddRow = newObj => {
 const { onAddRow } = this.props.options;
 if (onAddRow) {
    const colInfos = this.store.getColInfos();
    // JB: Added returning the value that onAddRow returns, to pass it to the caller
    const onAddRowResult = onAddRow(newObj, colInfos);
    if (onAddRowResult) {
       return onAddRowResult;
    }
 } 
  ... 

This ensures that a value/object returned by by the function assigned to onAddRow is passed to handleSaveBtnClick. The fix works in my copy of the BoostrapTable code in a production app without issues. We can even get rid ot the (not working) hack in ToolBar.handleSaveBtnClick:

handleSaveBtnClick = (newRow) => {
 if (!this.validateNewRow(newRow)) { // validation fail
   return;
 }
 const msg = this.props.onAddRow(newRow);
 if (msg) {
   notice('error', msg, '');
   this.clearTimeout();
   // shake form and hack prevent modal hide
   this.setState({
     shakeEditor: true
     // JB: This (not working hack) obviously is not needed (anymore)
     // , validateState: 'this is hack for prevent bootstrap modal hide

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
nguyenhosecommented, Jun 17, 2017

Ok, it worked. Thank you so much

1reaction
AllenFangcommented, Jun 17, 2017

HI, if you call the callback with explicit string(error message), which means current operation fail so that react-bootstrap-table will not close the modal. But If there’s no any error, you can just call the callback without any arguments, react-bootstrap-table will treat this operation as successful then close the modal.

Let me know if you have any concern.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Bootstrap modal hide is not working - Stack Overflow
I could not detect it in my local dev environment, but we're getting some reports saying that our modal isn't closing and the...
Read more >
How to Use Tables (The Java™ Tutorials > Creating a GUI ...
The table in SimpleTableDemo.java declares the column names in a String array: String[] columnNames = {"First ... Add row to selection/toggle row selection....
Read more >
3.1 - 3.7 - JavaScript in Dynaforms - ProcessMaker Wiki
When the user clicks on one of the buttons, the dialog box is hidden and the callback() function is executed which will add...
Read more >
<Modal/> Component - React-Bootstrap
Add dialogs to your site for lightboxes, user notifications, or completely ... Use <Modal/> in combination with other components to show or hide...
Read more >
Adding a new entry to a drop-down list when clicking its "Add ...
Inserting data into my database isn't a problem, but how do I get ... add dropdownlist item's content,you need to use dialog or...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found