mirror of
https://github.com/codex-team/editor.js
synced 2026-03-14 22:55:47 +01:00
Fix form submit on bold inline tool click (#2775)
This commit is contained in:
parent
15a8fb4bec
commit
b6674367a5
3 changed files with 40 additions and 1 deletions
|
|
@ -3,6 +3,7 @@
|
|||
### 2.30.2
|
||||
|
||||
- `Fix` – The onChange callback won't be fired when editor is initialized in the Read-Only mode
|
||||
- `Fix` – Prevent form submit on inline tool click
|
||||
|
||||
### 2.30.1
|
||||
|
||||
|
|
|
|||
|
|
@ -147,7 +147,9 @@ export class PopoverItemDefault extends PopoverItem {
|
|||
*/
|
||||
private make(params: PopoverItemDefaultParams, renderParams?: PopoverItemRenderParamsMap[PopoverItemType.Default]): HTMLElement {
|
||||
const tag = renderParams?.wrapperTag || 'div';
|
||||
const el = Dom.make(tag, css.container);
|
||||
const el = Dom.make(tag, css.container, {
|
||||
type: tag === 'button' ? 'button' : undefined,
|
||||
});
|
||||
|
||||
if (params.name) {
|
||||
el.dataset.itemName = params.name;
|
||||
|
|
|
|||
|
|
@ -76,6 +76,42 @@ describe('Inline Toolbar', () => {
|
|||
});
|
||||
});
|
||||
|
||||
it('should not submit form nesting editor when inline tool clicked', () => {
|
||||
cy.createEditor({
|
||||
data: {
|
||||
blocks: [
|
||||
{
|
||||
type: 'paragraph',
|
||||
data: {
|
||||
text: 'Some text',
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
|
||||
const onSubmit = cy.stub();
|
||||
|
||||
cy.document().then(doc => {
|
||||
const form = doc.createElement('form');
|
||||
|
||||
form.onsubmit = onSubmit;
|
||||
doc.body.appendChild(form);
|
||||
|
||||
/* Move editor to form */
|
||||
form.appendChild(doc.getElementById('editorjs'));
|
||||
|
||||
cy.get('[data-cy=editorjs]')
|
||||
.find('.ce-paragraph')
|
||||
.selectText('Some text');
|
||||
|
||||
cy.get('[data-item-name=bold]')
|
||||
.click();
|
||||
|
||||
expect(onSubmit).to.be.not.called;
|
||||
});
|
||||
});
|
||||
|
||||
describe('Conversion toolbar', () => {
|
||||
it('should restore caret after converting of a block', () => {
|
||||
cy.createEditor({
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue