Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions addon/components/bs-modal/footer.hbs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{{#let (ensure-safe-component (bs-default @buttonComponent (component "bs-button"))) as |Button|}}
<form class="modal-footer" ...attributes {{on "submit" (bs-default @onSubmit (bs-noop))}}>
<form class="modal-footer" ...attributes {{on "submit" this.handleSubmit}}>
{{#if (has-block)}}
{{yield}}
{{else}}
{{#if @submitTitle}}
<Button @onClick={{@onClose}}>{{bs-default @closeTitle "Ok"}}</Button>
<Button @type={{bs-default @submitButtonType "primary"}} @buttonType="submit" onSubmit={{@onSubmit}} disabled={{bs-default @submitDisabled false}}>{{@submitTitle}}</Button>
<Button @type={{bs-default @submitButtonType "primary"}} @buttonType="submit" disabled={{bs-default @submitDisabled false}}>{{@submitTitle}}</Button>
{{else}}
<Button @type="primary" @onClick={{@onClose}}>{{bs-default @closeTitle "Ok"}}</Button>
{{/if}}
Expand Down
13 changes: 11 additions & 2 deletions addon/components/bs-modal/footer.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,14 @@
* @event onClose
* @public
*/
import templateOnly from '@ember/component/template-only';
export default templateOnly();
import Component from '@glimmer/component';
import { action } from '@ember/object';

export default class ModalFooter extends Component {
@action
handleSubmit(event) {
// the footer is a <form>, so prevent the browser's native submission (and the page reload that comes with it)
event.preventDefault();
this.args.onSubmit?.();
}
}
12 changes: 9 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ember-bootstrap",
"version": "4.10.1",
"version": "4.10.2",
"description": "Bootstrap components for Ember.js",
"keywords": [
"ember-addon",
Expand Down Expand Up @@ -46,9 +46,12 @@
"*.js": "eslint --cache --fix"
},
"resolutions": {
"ember-cli-htmlbars/semver": "~7.0.0",
"ip-regex": "^2.1.0",
"ember-modifier": "^3.2.7"
"ember-modifier": "^3.2.7",
"lodash": "^4.18.1",
"testem": "~3.18.0",
"@embroider/addon-shim": "1.10.2",
"pkg-entry-points": "1.1.1"
},
"dependencies": {
"@ember/render-modifiers": "^2.1.0",
Expand Down Expand Up @@ -80,6 +83,9 @@
"ember-style-modifier": "^0.7.0",
"findup-sync": "^4.0.0",
"fs-extra": "^9.1.0",
"handlebars": "^4.7.10",
"lodash": "^4.18.1",
"postcss": "^8.5.29",
"resolve": "^1.18.1",
"rsvp": "^4.0.1",
"silent-error": "^1.0.1",
Expand Down
23 changes: 22 additions & 1 deletion tests/integration/components/bs-modal/footer-test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { module } from 'qunit';
import { setupRenderingTest } from 'ember-qunit';
import { render } from '@ember/test-helpers';
import { click, render } from '@ember/test-helpers';
import { test, defaultButtonClass } from '../../../helpers/bootstrap';
import hbs from 'htmlbars-inline-precompile';
import setupNoDeprecations from '../../../helpers/setup-no-deprecations';
Expand Down Expand Up @@ -43,6 +43,27 @@ module('Integration | Component | bs-modal/footer', function (hooks) {
assert.dom('.modal-footer button:last-child').hasText('submit', 'Submit button title is correct.');
});

test('Clicking submit button calls onSubmit and prevents native form submission', async function (assert) {
let submitCount = 0;
this.set('submit', () => submitCount++);
let defaultPrevented;
let listener = (event) => {
defaultPrevented = event.defaultPrevented;
// never let the test runner page navigate, even if the footer fails to prevent it
event.preventDefault();
};
window.addEventListener('submit', listener);
try {
await render(hbs`<BsModal::Footer @closeTitle="close" @submitTitle="submit" @onSubmit={{this.submit}} />`);
await click('.modal-footer button:last-child');
} finally {
window.removeEventListener('submit', listener);
}

assert.strictEqual(submitCount, 1, 'onSubmit is called once.');
assert.true(defaultPrevented, 'Native form submission is prevented.');
});

test('Footer can have a custom submitButtonType', async function (assert) {
await render(hbs`<BsModal::Footer @closeTitle="close" @submitTitle="submit" @submitButtonType="danger" />`);
assert.dom('.modal-footer button:last-child').hasClass('btn-danger', 'Submit button is a danger button.');
Expand Down
112 changes: 64 additions & 48 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1019,20 +1019,12 @@
ember-cli-version-checker "^5.1.2"
semver "^7.3.5"

"@embroider/addon-shim@1.8.3":
version "1.8.3"
resolved "https://registry.yarnpkg.com/@embroider/addon-shim/-/addon-shim-1.8.3.tgz#2368510b8ce42d50d02cb3289c32e260dfa34bd9"
integrity sha512-7pyHwzT6ESXc3nZsB8rfnirLkUhQWdvj6CkYH+0MUPN74mX4rslf7pnBqZE/KZkW3uBIaBYvU8fxi0hcKC/Paw==
dependencies:
"@embroider/shared-internals" "^1.8.3"
semver "^7.3.5"

"@embroider/addon-shim@^1.0.0":
version "1.10.0"
resolved "https://registry.yarnpkg.com/@embroider/addon-shim/-/addon-shim-1.10.0.tgz#7c3325e0939674290a9ca4ad7d744ee69313c0a0"
integrity sha512-gcJuHiXgnrzaU8NyU+2bMbtS6PNOr5v5B8OXBqaBvTCsMpXLvKo8OBOQFCoUN0rPX2J6VaFqrbi/371sMvzZug==
"@embroider/addon-shim@1.10.2", "@embroider/addon-shim@1.8.3", "@embroider/addon-shim@^1.0.0":
version "1.10.2"
resolved "https://registry.yarnpkg.com/@embroider/addon-shim/-/addon-shim-1.10.2.tgz#5164c65de0fd242422594c2f94b3c5eab4ab8e36"
integrity sha512-EfI9cJ5/3QSUJtwm7x1MXrx3TEa2p7RNgSHefy7fvGm8/DP1xUFL25nST1NaHbHcqR1UhMlrTtv5iUIDoVzeQQ==
dependencies:
"@embroider/shared-internals" "^3.0.0"
"@embroider/shared-internals" "^3.0.1"
broccoli-funnel "^3.0.8"
common-ancestor-path "^1.0.1"
semver "^7.3.8"
Expand Down Expand Up @@ -1083,7 +1075,7 @@
semver "^7.3.5"
typescript-memoize "^1.0.1"

"@embroider/shared-internals@3.0.0", "@embroider/shared-internals@^3.0.0":
"@embroider/shared-internals@3.0.0":
version "3.0.0"
resolved "https://registry.yarnpkg.com/@embroider/shared-internals/-/shared-internals-3.0.0.tgz#98251e6b99d36d64120361a449569ef5384b3812"
integrity sha512-5J5ipUMCAinQS38WW7wedruq5Z4VnHvNo+ZgOduw0PtI9w0CQWx7/HE+98PBDW8jclikeF+aHwF317vc1hwuzg==
Expand All @@ -1102,7 +1094,7 @@
semver "^7.3.5"
typescript-memoize "^1.0.1"

"@embroider/shared-internals@^1.0.0", "@embroider/shared-internals@^1.8.3":
"@embroider/shared-internals@^1.0.0":
version "1.8.3"
resolved "https://registry.yarnpkg.com/@embroider/shared-internals/-/shared-internals-1.8.3.tgz#52d868dc80016e9fe983552c0e516f437bf9b9f9"
integrity sha512-N5Gho6Qk8z5u+mxLCcMYAoQMbN4MmH+z2jXwQHVs859bxuZTxwF6kKtsybDAASCtd2YGxEmzcc1Ja/wM28824w==
Expand Down Expand Up @@ -1134,6 +1126,25 @@
semver "^7.3.5"
typescript-memoize "^1.0.1"

"@embroider/shared-internals@^3.0.1":
version "3.2.0"
resolved "https://registry.yarnpkg.com/@embroider/shared-internals/-/shared-internals-3.2.0.tgz#2379a2f320a72289bde72005dce0835359396f6a"
integrity sha512-TzLZnwfhhrNkdTVGGyysovvciFCwyxEgMbzF9AZMzNbFlXirhocQSpGjy9V4AQArklu4wDFRYqqe5GMKULGIkw==
dependencies:
babel-import-util "^3.0.1"
debug "^4.3.2"
ember-rfc176-data "^0.3.17"
fs-extra "^9.1.0"
is-subdir "^1.2.0"
js-string-escape "^1.0.1"
lodash "^4.17.21"
minimatch "^3.0.4"
pkg-entry-points "^1.1.1"
resolve-package-path "^4.0.1"
resolve.exports "^2.0.2"
semver "^7.3.5"
typescript-memoize "^1.0.1"

"@embroider/test-setup@^0.48.1":
version "0.48.1"
resolved "https://registry.yarnpkg.com/@embroider/test-setup/-/test-setup-0.48.1.tgz#f64da84f8241433d0ba92154fa1eb3137ecd4df8"
Expand Down Expand Up @@ -8601,12 +8612,12 @@ gulplog@^1.0.0:
dependencies:
glogg "^1.0.0"

handlebars@^4.0.4, handlebars@^4.3.1, handlebars@^4.7.3:
version "4.7.8"
resolved "https://registry.yarnpkg.com/handlebars/-/handlebars-4.7.8.tgz#41c42c18b1be2365439188c77c6afae71c0cd9e9"
integrity sha512-vafaFqs8MZkRrSX7sFVUdo3ap/eNiLnb4IakshzvP56X5Nr1iGKAIqdX6tMlm6HcNRIkr6AxO5jFEoJzzpT8aQ==
handlebars@^4.0.4, handlebars@^4.3.1, handlebars@^4.7.10, handlebars@^4.7.3:
version "4.7.10"
resolved "https://registry.yarnpkg.com/handlebars/-/handlebars-4.7.10.tgz#12419ea1b41391b3ffcf003f2164dcbce090c417"
integrity sha512-P5VJMVM7qgBn6vjXMw8WG9uVI+ncf2pi72j4de4yz5ZULLj2RGqLYaKOYGsgyrViQ0tePOVlN1tDCCXXtFqXKg==
dependencies:
minimist "^1.2.5"
minimist "^1.2.8"
neo-async "^2.6.2"
source-map "^0.6.1"
wordwrap "^1.0.0"
Expand Down Expand Up @@ -10616,10 +10627,10 @@ lodash.uniq@^4.2.0:
resolved "https://registry.yarnpkg.com/lodash.uniq/-/lodash.uniq-4.5.0.tgz#d0225373aeb652adc1bc82e4945339a842754773"
integrity sha512-xfBaXQd9ryd9dlSDvnvI0lvxfLJlYAZzXomUYzLKtUeOQvOP5piqAWuGtrhWeqaXK9hhoM/iyJc5AV+XfsX3HQ==

lodash@4.17.21, lodash@^4.0.0, lodash@^4.16.1, lodash@^4.17.12, lodash@^4.17.14, lodash@^4.17.15, lodash@^4.17.19, lodash@^4.17.21, lodash@^4.17.4, lodash@^4.6.1:
version "4.17.21"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c"
integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==
lodash@4.17.21, lodash@^4.0.0, lodash@^4.16.1, lodash@^4.17.12, lodash@^4.17.14, lodash@^4.17.15, lodash@^4.17.19, lodash@^4.17.21, lodash@^4.17.4, lodash@^4.18.1, lodash@^4.6.1:
version "4.18.1"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.18.1.tgz#ff2b66c1f6326d59513de2407bf881439812771c"
integrity sha512-dMInicTPVE8d1e5otfwmmjlxkZoUpiVLwyeTdUsi/Caj/gfzzblBcCE5sRHV/AsjuCmxWrte2TNGSYuCeCq+0Q==

log-symbols@4.0.0:
version "4.0.0"
Expand Down Expand Up @@ -11113,7 +11124,7 @@ minimist@^0.2.1:
resolved "https://registry.yarnpkg.com/minimist/-/minimist-0.2.4.tgz#0085d5501e29033748a2f2a4da0180142697a475"
integrity sha512-Pkrrm8NjyQ8yVt8Am9M+yUt74zE3iokhzbG1bFVNjLB92vwM71hf40RkEsryg98BujhVOncKm/C1xROxZ030LQ==

minimist@^1.1.0, minimist@^1.1.1, minimist@^1.2.0, minimist@^1.2.5, minimist@^1.2.6:
minimist@^1.1.0, minimist@^1.1.1, minimist@^1.2.0, minimist@^1.2.6, minimist@^1.2.8:
version "1.2.8"
resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.8.tgz#c1a464e7693302e082a075cee0c057741ac4772c"
integrity sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==
Expand Down Expand Up @@ -11351,10 +11362,10 @@ nanoid@3.1.20:
resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.1.20.tgz#badc263c6b1dcf14b71efaa85f6ab4c1d6cfc788"
integrity sha512-a1cQNyczgKbLX9jwbS/+d7W8fX/RfgYR7lVWwWOGIPNgK2m0MWvrGF6/m4kk6U3QcFMnZf3RIhL0v2Jgh/0Uxw==

nanoid@^3.3.11:
version "3.3.11"
resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.3.11.tgz#4f4f112cefbe303202f2199838128936266d185b"
integrity sha512-N8SpfPUnUp1bK+PMYW8qSWdl9U+wwNWI4QKxOYDy9JAro3WMX7p2OeVRF9v+347pnakNevPmiHhNmZ2HbFA76w==
nanoid@^3.3.19:
version "3.3.20"
resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.3.20.tgz#dfd4444d85aa10111ef66ba85ed72e08ba0855d8"
integrity sha512-uKdg2G3GNCKQn9byYOpxbGqrT2fGO5KRt5J/8b3pok8rT6qxGWF6hxMyJiEYtAf+FVyYuD9hRaDqX5uPFYJ4ZQ==

nanomatch@^1.2.9:
version "1.2.13"
Expand Down Expand Up @@ -12369,7 +12380,7 @@ pkg-dir@^5.0.0:
dependencies:
find-up "^5.0.0"

pkg-entry-points@^1.1.0:
pkg-entry-points@1.1.1, pkg-entry-points@^1.1.0, pkg-entry-points@^1.1.1:
version "1.1.1"
resolved "https://registry.yarnpkg.com/pkg-entry-points/-/pkg-entry-points-1.1.1.tgz#d5cd87f934e873bf73143ed1d0baf637e5f8fda4"
integrity sha512-BhZa7iaPmB4b3vKIACoppyUoYn8/sFs17VJJtzrzPZvEnN2nqrgg911tdL65lA2m1ml6UI3iPeYbZQ4VXpn1mA==
Expand Down Expand Up @@ -12459,14 +12470,14 @@ postcss-value-parser@^4.1.0:
resolved "https://registry.yarnpkg.com/postcss-value-parser/-/postcss-value-parser-4.2.0.tgz#723c09920836ba6d3e5af019f92bc0971c02e514"
integrity sha512-1NNCs6uurfkVbeXG4S8JFT9t19m45ICnif8zWLd5oPSZ50QnwMfK+H3jv408d4jw/7Bttv5axS5IiHoLaVNHeQ==

postcss@^8.2.15:
version "8.5.6"
resolved "https://registry.yarnpkg.com/postcss/-/postcss-8.5.6.tgz#2825006615a619b4f62a9e7426cc120b349a8f3c"
integrity sha512-3Ybi1tAuwAP9s0r1UQ2J4n5Y0G05bJkpUIO0/bI9MhwmD70S5aTWbXGBwxHrelT+XM1k6dM0pk+SwNkpTRN7Pg==
postcss@^8.2.15, postcss@^8.5.29:
version "8.5.29"
resolved "https://registry.yarnpkg.com/postcss/-/postcss-8.5.29.tgz#086a0ded2c0257c71efb8c68776b477774714b4a"
integrity sha512-49cGhUbXj8Qenv0iTMxA1cFBzxXoctpC9Ujd77t1WcbJIr6nF/eI7g/8MgxrYldFRuAXvja7xQRwavoW7kgrxQ==
dependencies:
nanoid "^3.3.11"
nanoid "^3.3.19"
picocolors "^1.1.1"
source-map-js "^1.2.1"
source-map-js "^1.2.2"

prelude-ls@^1.2.1:
version "1.2.1"
Expand Down Expand Up @@ -13644,11 +13655,6 @@ semver@^7.2.1, semver@^7.3.2, semver@^7.3.4, semver@^7.3.5, semver@^7.3.8:
resolved "https://registry.yarnpkg.com/semver/-/semver-7.7.2.tgz#67d99fdcd35cec21e6f8b87a7fd515a33f982b58"
integrity sha512-RF0Fw+rO5AMf9MAyaRXI4AV0Ulj5lMHqVxxdSgiVbixSCXoEmmX/jk0CuJw4+3SqroYO9VoUh+HcuJivvtJemA==

semver@~7.0.0:
version "7.0.0"
resolved "https://registry.yarnpkg.com/semver/-/semver-7.0.0.tgz#5f3ca35761e47e05b206c6daff2cf814f0316b8e"
integrity sha512-+GB6zVA9LWh6zovYQLALHwv5rb2PHGlJi3lfiqIHxR0uuwCgefcOJc59v9fv1w8GbStwxuuqqAjI9NMAOOgq1A==

send@0.19.0:
version "0.19.0"
resolved "https://registry.yarnpkg.com/send/-/send-0.19.0.tgz#bbc5a388c8ea6c048967049dbeac0e4a3f09d7f8"
Expand Down Expand Up @@ -14092,11 +14098,16 @@ source-list-map@^2.0.0:
resolved "https://registry.yarnpkg.com/source-list-map/-/source-list-map-2.0.1.tgz#3993bd873bfc48479cca9ea3a547835c7c154b34"
integrity sha512-qnQ7gVMxGNxsiL4lEuJwe/To8UnK7fAnmbGEEH8RpLouuKbeEm0lhbQVFIrNSuB+G7tVrAlVsZgETT5nljf+Iw==

source-map-js@^1.0.1, source-map-js@^1.2.1:
source-map-js@^1.0.1:
version "1.2.1"
resolved "https://registry.yarnpkg.com/source-map-js/-/source-map-js-1.2.1.tgz#1ce5650fddd87abc099eda37dcff024c2667ae46"
integrity sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==

source-map-js@^1.2.2:
version "1.2.2"
resolved "https://registry.yarnpkg.com/source-map-js/-/source-map-js-1.2.2.tgz#79fb88d97535a21cb27162cb05d211b67acea4ab"
integrity sha512-KGj/8Y43x35aZVDtt+J4mK1hoLGHULMYfSkODJNQjNDC3oW1PqPoxMwo0pLUsWM/UEGzON/NxeHywEfNXNP3Vw==

source-map-resolve@^0.5.0:
version "0.5.3"
resolved "https://registry.yarnpkg.com/source-map-resolve/-/source-map-resolve-0.5.3.tgz#190866bece7553e1f8f267a2ee82c606b5509a1a"
Expand Down Expand Up @@ -14769,10 +14780,10 @@ testdouble@^3.2.6:
stringify-object-es5 "^2.5.0"
theredoc "^1.0.0"

testem@^3.2.0:
version "3.16.0"
resolved "https://registry.yarnpkg.com/testem/-/testem-3.16.0.tgz#9f54304a53bf0f4ca218c2229f33f9620a2a457b"
integrity sha512-TKQ3CuG/u+vDa7IUQgRQHN753wjDlgYMWE45KF5WkXyWjTNxXHPrY0qPBmHWI+kDYWc3zsJqzbS7pdzt5sc33A==
testem@^3.2.0, testem@~3.18.0:
version "3.18.0"
resolved "https://registry.yarnpkg.com/testem/-/testem-3.18.0.tgz#e3b5b32a705212f96072281f70caf6630fcd352d"
integrity sha512-HEj+HSms8aM4GLn2bEkcR4rVb3Fr0C34uEUATbhVr/UirZkXh+iv+TuA7IGLC4KVGmuYSA0SjAYckci82hShEQ==
dependencies:
"@xmldom/xmldom" "^0.8.0"
backbone "^1.1.2"
Expand All @@ -14798,7 +14809,7 @@ testem@^3.2.0:
spawn-args "^0.2.0"
styled_string "0.0.1"
tap-parser "^7.0.0"
tmp "0.0.33"
tmp "^0.2.5"

text-table@^0.2.0:
version "0.2.0"
Expand Down Expand Up @@ -14945,7 +14956,7 @@ tmp@0.0.28:
dependencies:
os-tmpdir "~1.0.1"

tmp@0.0.33, tmp@^0.0.33:
tmp@^0.0.33:
version "0.0.33"
resolved "https://registry.yarnpkg.com/tmp/-/tmp-0.0.33.tgz#6d34335889768d21b2bcda0aa277ced3b1bfadf9"
integrity sha512-jRCJlojKnZ3addtTOjdIqoRuPEKBvNXcGYqzO6zWZX8KfKEpnGY5jfggJQ3EjKuu8D4bJRr0y+cYJFmYbImXGw==
Expand All @@ -14964,6 +14975,11 @@ tmp@^0.2.1:
resolved "https://registry.yarnpkg.com/tmp/-/tmp-0.2.3.tgz#eb783cc22bc1e8bebd0671476d46ea4eb32a79ae"
integrity sha512-nZD7m9iCPC5g0pYmcaxogYKggSfLsdxl8of3Q/oIbqCqLLIO9IAF0GWjX1z9NZRHPiXv8Wex4yDCaZsgEw0Y8w==

tmp@^0.2.5:
version "0.2.7"
resolved "https://registry.yarnpkg.com/tmp/-/tmp-0.2.7.tgz#26f4db11d1601ce8012dcb8a798ece1c06a99059"
integrity sha512-e0votIpp4Uo2AJYSzVHV6xCcawuiez3DzqDAbrTc3YxBkplN6e+dM13ZeIcZnDg/QpSuU2zfZ3rzwY8ukEnaXw==

tmpl@1.0.5:
version "1.0.5"
resolved "https://registry.yarnpkg.com/tmpl/-/tmpl-1.0.5.tgz#8683e0b902bb9c20c4f726e3c0b69f36518c07cc"
Expand Down
Loading