Getting bootstrap modal to work with Liveview

I am trying to use bootstrap 5 modal with liveview and there are some problems that i am facing.

if @live_action in [:new] do
  bootstrap modal code goes here
<%= live_patch "Add User", to: user_route_example, "data-bs-toggle": "modal", "data-bs-target": "#exampleModal"%>

When I click on the btn, I get an err in the browser console. But the 2nd time I click on it, the modal shows up. How can I fix this?

The other issue that i am facing is, when I submit the form via liveview, the modal goes away but the background of that modal stays. What should I do to fix that as well??

I used Js hooks to show the modal. But when i submit the form , the modal is closed but the background still reamains. How do i get rid of the background?