bestguy / sveltestrap

Bootstrap 4 & 5 components for Svelte
https://sveltestrap.js.org
MIT License
1.3k stars 183 forks source link

fix: disabled button with href attribute #449

Closed demetrius-mp closed 2 years ago

demetrius-mp commented 2 years ago

fixes #405 used this as solution. also, added type to the colors: ButtonColor[] array to remove vscode type warnings.

demetrius-mp commented 2 years ago

actually, if you prefer, it can also be solved the same way you did right here. jsut let me know, i could open another PR using your method.

demetrius-mp commented 2 years ago

just realized that using css to "disable" the link, gives this test error:

 FAIL  src/__test__/Button.spec.js
  ● Button › should render as link if href specified

    expect(received).toBe(expected) // Object.is equality

    Expected: "btn btn-secondary"
    Received: "btn btn-secondary svelte-1orwa0"

      68 |     const container = renderButton({ href: 'http://example.com/' });
      69 |     const link = container.querySelector('a');
    > 70 |     expect(link.className).toBe('btn btn-secondary');
         |                            ^
      71 |     expect(link.href).toBe('http://example.com/');
      72 |   });
      73 |

going to try and solve this by eating the click event with js.