vue-js-modal icon indicating copy to clipboard operation
vue-js-modal copied to clipboard

scrollable not working when adaptive mode is true

Open ShekhSaifuddin007 opened this issue 4 years ago • 21 comments

Problem:

I'm using this plugin the problem is when I use :adaptive="true" I can not scroll the modal when the modal height is bigger than the screen, how can I solve this.?

Version:

"vue-js-modal": "^2.0.0-rc.6"

Example & screenshots:

this my setup

<modal name="quick-view"
      width="90%"
      height="auto"
      :maxWidth="1000"
      :maxHeight="600"
      :adaptive="true"
      :scrollable="true">
     long content goes here
     .......................................................................
     ........................................................................
     ........................................................................
</modal>

is my setup is correct or I missed something..

I have checked StackOverflow for solutions and 100% sure that this issue is not related to my code.

ShekhSaifuddin007 avatar Mar 15 '21 19:03 ShekhSaifuddin007

@euvl Is there something to make only x-axis adaptive?

Romko775 avatar Mar 17 '21 13:03 Romko775

@euvl can you suggest to me how can get this to work with :adaptive="true" if there is no way to do it then how can we get that functionality without :adaptive="true"

ShekhSaifuddin007 avatar Mar 19 '21 08:03 ShekhSaifuddin007

Same issue, been fixing this for 2 months now but got no luck.

jrbautista10 avatar Apr 14 '21 17:04 jrbautista10

As a temporary workaround until a PR is merged you can extend the component and override the "autoHeight" computed:

import Vue from 'vue';
import VModal from 'vue-js-modal/dist/ssr.nocss';
import AbstractModal from 'vue-js-modal/src/components/Modal';

Vue.use(VModal, {
  componentName: 'abstract-modal',
});

Vue.component('vue-modal', {
  extends: AbstractModal,
  computed: {
    /**
     * Fix using "adaptive" and "scrollable" at the same time
     */
    autoHeight () {
      if (this.scrollable) {
        return 'auto';
      }
      return AbstractModal.computed.autoHeight.apply(this);
    }
  }
});

justwiebe avatar Apr 26 '21 17:04 justwiebe

@BakoviDagi good thing but where or how I can find the AbstractModal in my project I can't find this

ShekhSaifuddin007 avatar May 03 '21 18:05 ShekhSaifuddin007

@BakoviDagi good thing but where or how I can find the AbstractModal in my project I can't find this

import AbstractModal from 'vue-js-modal/src/components/Modal';

try this

Romko775 avatar May 06 '21 15:05 Romko775

@BakoviDagi Thanks brother it's working,

ShekhSaifuddin007 avatar May 10 '21 17:05 ShekhSaifuddin007

@Romko775 @ShekhSaifuddin007 How can I find AbstracModal because it shows an error that the Modal could not find? image

GuasaPlay avatar May 19 '21 04:05 GuasaPlay

@GuasaPlay paste the above code inside your app.js it will work

ShekhSaifuddin007 avatar May 19 '21 06:05 ShekhSaifuddin007

@SaurabhKharivale I'm using Nuxtjs so there is no app.js file, but there is a nuxt.config.js file. 😕

GuasaPlay avatar May 19 '21 14:05 GuasaPlay

@GuasaPlay nuxt app has main.js which is compiled by webpack paste the code inside main.js

ShekhSaifuddin007 avatar May 19 '21 14:05 ShekhSaifuddin007

@GuasaPlay I'm also using nuxt. You can just use a plugin: nuxt.config.js:

export default: {
  // ...
  plugins: ['~/plugins/vue-js-modal.js']
}

plugins/vue-js-modal.js:

import Vue from 'vue';
import VModal from 'vue-js-modal/dist/ssr.nocss';
import AbstractModal from 'vue-js-modal/src/components/Modal';

Vue.use(VModal, {
  componentName: 'abstract-modal',
});

Vue.component('vue-modal', {
  extends: AbstractModal,
  computed: {
    /**
     * Fix using "adaptive" and "scrollable" at the same time
     */
    autoHeight () {
      if (this.scrollable) {
        return 'auto';
      }
      return AbstractModal.computed.autoHeight.apply(this);
    }
  }
});

justwiebe avatar May 19 '21 15:05 justwiebe

@ShekhSaifuddin007 following css rule fixed the scrolling issue for me

.vm--modal {
  height: auto !important;
}

SaurabhKharivale avatar May 19 '21 17:05 SaurabhKharivale

@BakoviDagi My configuration is the same, but it still doesn't work. Maybe it's the nuxt version

GuasaPlay avatar May 19 '21 18:05 GuasaPlay

@SaurabhKharivale Thanks it's working

GuasaPlay avatar May 19 '21 18:05 GuasaPlay

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Jun 26 '21 03:06 stale[bot]

I have the same issue.

jtrod avatar Jun 30 '21 20:06 jtrod

issue still existing today (so the stale bot keeps its cool) meanwhile, the css fix is quite nice : https://github.com/euvl/vue-js-modal/issues/674#issuecomment-844301259

pierrexp9 avatar Jul 08 '21 21:07 pierrexp9

This Nuxt soution does in fact fix the issue for me, as well as the "bouncing" effect from #624. However, there are a couple tweaks I had to make that weren't obvious at the time (to me).

A. You have to add .vue to the end of this line import AbstractModal from 'vue-js-modal/src/components/Modal.vue' B: This one is obvious in retrospect, but you have to use <VueModal /> in your templates now instead of just <Modal />. Obviously you can change the name of the component to whatever you want, so this one is less important. Just a silly gotcha that I fell for.

Roninii avatar Aug 05 '21 03:08 Roninii

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Jan 09 '22 07:01 stale[bot]

Had the same issue today, using Vue.js 2.

Both solutions @BakoviDagi and @SaurabhKharivale seem to work but the latter is more simple so implementing that one,

DimitriBe avatar Apr 28 '22 14:04 DimitriBe