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.

close-only for modal

See original GitHub issue

Hello,

Right now, there is an option for ok-only to display action button. Would it be possible to add a cancel-only prop, so we can show only the cancel button ?

Simple use case would be: modal containing a call to action, but the user cannot meet the requirement, so the only choice is to close the modale. ex:

    <b-modal
      @ok="submit"
      @shown="fetchContent"
      :ok-title="trans('submit')"
      :cancel-only="errors.length > 0"
    ></b-modal>

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:11 (8 by maintainers)

github_iconTop GitHub Comments

3reactions
tmorehousecommented, May 29, 2017

When overriding the footer, you are removing the “built in” OK & Cancel buttons, so you are also removing the “built-in” event handlers, as all the logic is now moved into your own app or component. So you’ll have to write your own handler that checks for a condition and prevents the modals visibility from being set to false (basically the same logic you would have used when calling e.cancel()):

methods: {
  cancel() {
    // Close the modal
    this.showModal = false;
  },
  save() {
     if (someTest === true) {
       // Close the modal if conditions are met
       this.showModal = false;
     } else {
        alert("You didn't do something");
        // this.showModal left as `true`
     }
   }
}
2reactions
tmorehousecommented, Jun 23, 2017

@tristanbes You can also work around this by firing the components hde() method and pass the boolean primitives true or false to hide() (note they must be booleans, not truthy/falsey values). This will trigger the ok and cancel events on the component:

<b-modal ref="my_modal" @ok="save" @cancel="cancel">
  <!-- modal content here ->
  <template slot="modal-footer">
    <b-btn v-if="selected !== 'ok'" variant="danger"
       @click="$refs.my_modal.hide(false)"
     >{{ 'cancel'|trans }}</b-btn>
    <b-btn v-if="selected !== 'cancel'" variant="primary"
       @click="$refs.my_modal.hide(true)"
    >{{ 'ok'|trans }}</b-btn>
  </template>
</b-modal>
...

```js
methods: { 
  save(e) {
    return e.cancel();
  } 
  cancel(e) {
    return e.cancel();
  } 
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

modal within a modal - how to close only the inner modal
I added an id to the button used to close the inner modal (say 'closeMyModal), and then defined the following function: $(".closeMyModal").click ...
Read more >
Modal - Bootstrap
Modals are built with HTML, CSS, and JavaScript. · Clicking on the modal “backdrop” will automatically close the modal. · Bootstrap only supports...
Read more >
Modal Form Prevent Closing - Material Design for Bootstrap
Hi Team - I have a modal form that opens and fires when a button is clicked. The modal form is displayed as...
Read more >
Bootstrap close only one modal, Close active modal, Data-dismiss ...
Bootstrap close only one modal. Click the above button to open Bootstrap modal. Now, click outside of the modal and check if its...
Read more >
Modal and overlay behavior - When to close the modal
If a modal contains critical information that cannot be recovered, it should close only when a close button is explicitly clicked.
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