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.

"show" class is added to modals too late

See original GitHub issue

Describe the bug

When a modal is shown, it uses a transition, however at the moment isShow is set in onAfterEnter which doesn’t happen until the end of the transition. This means you get sequential transitions or a perceived delay, also the buttons which should show disabled during the transition are always enabled.

Steps to reproduce the bug

  1. Extend the transition time of fade to make it easier to see
  2. Trigger open of a modal
  3. You will see the backdrop fade in
  4. Then after that the show class is added and you see the modal show transition

Expected behavior

The show class needs to be added at the same point as a enter-to class would be added, i.e. the very next frame after enter.

Versions

Libraries:

  • BootstrapVue: 2.4.1
  • Bootstrap: 4.4.1
  • Vue: 2.6.10

Fix

To solve the issue I changed the following here: https://github.com/bootstrap-vue/bootstrap-vue/blob/7a34f737be4825bfc1313463b13e2edb529f9a7c/src/components/modal/modal.js#L616

onEnter() {
    this.isBlock = true;
    window.requestAnimationFrame(() => {
        window.requestAnimationFrame(() => {
            this.isShow = true;
        });
    });
}

And also remove this.isShow = true; from onAfterEnter

Ideally I’d like to use nextFrame(() => {this.isShow = true;}) from the built in transition lib in Vue but I couldn’t see a way to import that definition. https://github.com/vuejs/vue/blob/4de4649d9637262a9b007720b59f80ac72a5620c/src/platforms/web/runtime/transition-util.js#L67

Demo link for problem and solution

https://codepen.io/sonicisthebest/pen/LYVGpvJ

Issue Analytics

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

github_iconTop GitHub Comments

2reactions
philipmountifieldcommented, Feb 17, 2020

Sure I’ll take a look.

0reactions
jacobmllr95commented, Feb 17, 2020

@philipmountifield Thanks for the research! Do you want’t to come up with a PR to add the second requestAF() in yourself?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Bootstrap Modal immediately disappearing - Stack Overflow
A Likely Cause. This is typical behavior for when the JavaScript for the Modal plugin gets loaded twice. Please check to make sure...
Read more >
Modal · Bootstrap v5.1
Use Bootstrap's JavaScript modal plugin to add dialogs to your site for lightboxes, user notifications, or completely custom content.
Read more >
Drop or Withdraw from Classes - FIU | OneStop
If you drop a class before the add/drop deadline, there are no consequences as long as you maintain a full-time course load.
Read more >
Bootstrap Modal Dialog showing under Modal Background
I've repeatedly run into the following problem with Bootstrap's modal dialog where the dialog ends up showing underneath the modal ...
Read more >
What Is a Modal Verb? - Ginger Software
A modal is a type of auxiliary (helping) verb that is used to express: ability, ... Tom can write poetry very well. ......
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