svelma icon indicating copy to clipboard operation
svelma copied to clipboard

Dialog Alert won't close due to: Uncaught (in promise) TypeError: resolve is not a function

Open KostjaStein opened this issue 4 years ago • 5 comments

How to reproduce:

  1. go to: https://c0bra.github.io/svelma/components/dialog/
  2. click "Dialog" button
  3. click "OK" button (within alert dialog)

Dialog won't close, console output: Uncaught (in promise) TypeError: resolve is not a function at HTMLButtonElement.confirm (Dialog.svelte:146)

Dialog.svelte:146 resolve(hasInput ? prompt: true)

Dialog.svelte:85-87 // export let showClose = true let resolve // export let promise = new Promise((fulfil) => (resolve = fulfil))

KostjaStein avatar Jan 04 '22 08:01 KostjaStein

The doc and demo was outdated. I have just updated the doc link.

https://docs-abbychau.vercel.app/svelma/components/dialog

abbychau avatar Jan 06 '22 05:01 abbychau

Thank you! The documentation demo (at the adress you provided) is working. However, the same issue occures within the library itself. I'm using the library (version 0.4.5) and observe the same behavior as was/is present in the doc demo (at this adress: https://c0bra.github.io/svelma/components/dialog/). I'm not sure however, whether the problem is caused by the fact, that i'm using TypeScript for my project. I will give it a try to solve the issue and on sucess post the fix to help other TypeScript users. Do you have any hint what may cause the problem if the library is used within a TypeScript project?

KostjaStein avatar Jan 07 '22 09:01 KostjaStein

You could link with git main branch instead of using 0.4.5

git clone https://github.com/c0bra/svelma.git
cd my-project 
pnpm link ../svelma 

devDependencies:
- svelma 0.4.5
+ svelma 0.4.5 <- ../svelma

mcurcija avatar Mar 09 '22 22:03 mcurcija

Build from local git is also fine

cd svelma 
pnpm run build 
cd public/build
pnpm pack 

During pack svelma-0.4.5.tgz is created in project root. Copy svelma-0.4.5.tgz to the root of your project and do following (don't forget to unlink if it was linked as suggested in previous comment):

# remove first
pnpm rm -D svelma
# and add local package instead
pnpm add -D file:svelma-0.4.5.tgz

mcurcija avatar Mar 09 '22 22:03 mcurcija

Any update on this? The public version seems to be still broken.

CherryDT avatar May 06 '22 18:05 CherryDT