Comments (4)
Hi noelc10,
It looks like the issue you're encountering may be due to a misalignment in your structure with Preline's overlay component. To ensure compatibility with its JavaScript functionality, your HTML structure needs to match the expected format.
In your case, I see you're using the following code, which works when data-hs-overlay-keyboard=" false"
is provided to the overlay container. You can replicate a similar structure in Nuxt for it to function properly:
<button
type="button"
class="py-3 px-4 inline-flex items-center gap-x-2 text-sm font-semibold rounded-lg border border-transparent bg-blue-600 text-white hover:bg-blue-700 disabled:opacity-50 disabled:pointer-events-none"
data-hs-overlay="#hs-basic-modal"
>
Open modal
</button>
<div
id="hs-basic-modal"
class="hs-overlay hs-overlay-open:opacity-100 hs-overlay-open:duration-500 hidden size-full fixed top-0 start-0 z-[80] opacity-0 overflow-x-hidden transition-all overflow-y-auto pointer-events-none"
data-hs-overlay-keyboard="false"
>
<!-- Modal content -->
</div>
Just ensure two things:
- Provide
data-hs-overlay="#hs-basic-modal"
to the trigger button. - Add the
hs-overlay
class to the container for the target.
With this structure, the overlay should function as expected. Feel free to reach out if you need further assistance with other JavaScript options.
from preline.
Hello @SHVM-09 ,
Thank you for helping me with this issue. I apply your solution and also follow your suggestion and came up with this re-construction of my template:
<template>
<div>
<button
type="button"
class="none"
data-hs-overlay="#articleDetailsModal"
></button>
<div
id="articleDetailsModal"
class="hs-overlay hidden size-full fixed top-0 start-0 z-[80] overflow-x-hidden overflow-y-auto [--overlay-backdrop:static]"
data-hs-overlay-keyboard="false"
>
<div
class="hs-overlay-open:mt-7 hs-overlay-open:opacity-100 hs-overlay-open:duration-500 mt-0 opacity-0 ease-out transition-all sm:max-w-lg sm:w-full m-3 sm:mx-auto h-[calc(100%-3.5rem)] min-h-[calc(100%-3.5rem)] flex items-center"
>
<div
class="w-full max-h-full overflow-hidden flex flex-col bg-white border shadow-sm rounded-xl pointer-events-auto dark:bg-gray-800 dark:border-gray-700 dark:shadow-slate-700/[.7]"
>
<div class="flex justify-between items-center py-3 px-4">
<div class="flex-col">
<h3
v-show="!loading && article"
class="truncate text-lg font-bold text-gray-800 dark:text-white"
>
{{ article.title }}
</h3>
<p class="text-xs text-gray-500 dark:text-gray-500">
{{ $dayjs(article.created_at).fromNow() }} by
{{ article.user?.name }}
</p>
</div>
<div v-show="loading" class="w-full flex animate-pulse">
<div class="ms-4 mt-2 w-full">
<h3
class="h-4 bg-gray-200 rounded-full dark:bg-gray-700"
style="width: 40%"
>
</h3>
</div>
</div>
<button
type="button"
class="flex justify-center items-center size-7 text-sm font-semibold rounded-full border border-transparent text-gray-800 hover:bg-gray-100 disabled:opacity-50 disabled:pointer-events-none dark:text-white dark:hover:bg-gray-700"
@click="closeArticleDetails()"
>
<span class="sr-only">Close</span>
<span class="flex-shrink-0 size-4 i-[mdi--close]"></span>
</button>
</div>
<div class="p-4 overflow-auto">
<div
v-show="!loading && article"
class="mt-1 text-gray-500 dark:text-gray-400"
>
<div v-html="article.content"></div>
</div>
<div v-show="loading" class="w-full flex animate-pulse">
<div class="ms-4 mt-2 w-full">
<ul class="mt-5 space-y-3 list-none">
<li
class="w-full h-4 bg-gray-200 rounded-full dark:bg-gray-700"
></li>
<li
class="w-1/2 h-4 bg-gray-200 rounded-full dark:bg-gray-700"
></li>
<li
class="w-1/4 h-4 bg-gray-200 rounded-full dark:bg-gray-700"
></li>
</ul>
</div>
</div>
<div
class="mt-12 py-3 flex items-center text-sm text-gray-800 after:flex-1 after:border-t after:border-gray-200 after:ms-6 dark:text-white dark:after:border-gray-600"
>
Comments
</div>
<CommentsSection
:article-id="article?.id ?? 0"
:loading="loading"
/>
</div>
</div>
</div>
</div>
</div>
</template>
Unfortunately, It still doesn't work. I can still able to close the modal when pressing ESC key. Just to let you aware, I programmatically open the modal with the openArticleDetails()
function with a HSOverlay.open("#articleDetailsModal")
that triggers the open state of the modal if the specific page URL is loaded. And the modal button is some sort of a compliance of the construction of the modal component for the sake to make it work. But it seems that some of the needed attributes of the modal doesn't seems to work.
Let me know if there is anything that I miss with your solution or to my implementation of the said solution above.
Thanks for the response, I appreciate it a lot.
from preline.
Hello noelc10,
I'd like to verify whether you've updated to Preline v2.1.0 or if you're still using an older version. The issue you're encountering has been resolved in the latest update. If you haven't upgraded yet, I suggest doing so to resolve the issue. If this isn't the case, please let me know, and I can provide you with the entires HTML + JS code from my end where it's functioning correctly, either in a zip file or another format.
Best regards
from preline.
Hey @SHVM-09,
Thank you for your response. I upgrade the preline to its latest version and its working now. I appreciate your effort on helping me with this issue. I hope you'll able to resolve my other issues submitted here.
Best regards.
from preline.
Related Issues (20)
- Dropdown with Nuxt 3 unable to work HOT 2
- Request for Tree View Component HOT 2
- self is not defined in vue + inertia+laravel
- Difficulty Implementing Preline UI Tabs Plugin in Next.js Pages Router
- Preline not works sometime in Vuejs HOT 3
- Scrollspy: jump-clicked element remains highlighted even if scrolled elsewhere
- Advanced select not working with dynamic values and no option to select or disable. HOT 1
- Advanced select disappears after Livewire second render
- I can't use preline with Headless UI HOT 1
- Add Keyboard Shortcut for Modal on Docs
- Fetch Request Reopens Modal Backdrop Problem
- Changing Arrow color on select box HOT 2
- WYSIWYG editor example (tiptap third party plugin integration): lists not working HOT 2
- TypeError: Cannot read properties of undefined (reading 'length') HOT 1
- Next JS / Preline doesn't load, need to change page to get JS loaded HOT 2
- how to use the steps plugin in angular? HOT 1
- Advance Select and multiple option value not detected using Livewire 3
- Mega Menu with hover effect is flickering when trying to get cursor from link to menu HOT 1
- Advance select with search not working HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from preline.