Fixed #85: pressing enter in an input in a form containing a JSONEditor too breaks submitting the form

This commit is contained in:
jos 2016-11-01 21:00:21 +01:00
parent d73665acf3
commit df12832a6b
8 changed files with 24 additions and 0 deletions

View File

@ -3,6 +3,11 @@
https://github.com/josdejong/jsoneditor
## not yet released, version 5.5.10
- Fixed #85: pressing enter in an input in a form containing a JSONEditor too
breaks submitting the form.
## 2016-10-17, version 5.5.9
- Fixed #329: Editor showing duplicate key warnings for keys defined on the

View File

@ -42,6 +42,7 @@ function ContextMenu (items, options) {
// create a (non-visible) button to set the focus to the menu
var focusButton = document.createElement('button');
focusButton.type = 'button';
dom.focusButton = focusButton;
var li = document.createElement('li');
li.style.overflow = 'hidden';
@ -68,6 +69,7 @@ function ContextMenu (items, options) {
// create a button in the menu item
var button = document.createElement('button');
button.type = 'button';
button.className = item.className;
domItem.button = button;
if (item.title) {
@ -96,6 +98,7 @@ function ContextMenu (items, options) {
button.className += ' jsoneditor-default';
var buttonExpand = document.createElement('button');
buttonExpand.type = 'button';
domItem.buttonExpand = buttonExpand;
buttonExpand.className = 'jsoneditor-expand';
buttonExpand.innerHTML = '<div class="jsoneditor-expand"></div>';

View File

@ -72,6 +72,7 @@ function ModeSwitcher(container, modes, current, onSwitch) {
// create the html element
var box = document.createElement('button');
box.type = 'button';
box.className = 'jsoneditor-modes jsoneditor-separator';
box.innerHTML = currentTitle + ' &#x25BE;';
box.title = 'Switch editor mode';

View File

@ -164,6 +164,7 @@ Node.prototype.setError = function (error, child) {
popover.appendChild(document.createTextNode(error.message));
var button = document.createElement('button');
button.type = 'button';
button.className = 'jsoneditor-schema-error';
button.appendChild(popover);
@ -1485,6 +1486,7 @@ Node.prototype.getDom = function() {
// create draggable area
if (this.parent) {
var domDrag = document.createElement('button');
domDrag.type = 'button';
dom.drag = domDrag;
domDrag.className = 'jsoneditor-dragarea';
domDrag.title = 'Drag to move this field (Alt+Shift+Arrows)';
@ -1496,6 +1498,7 @@ Node.prototype.getDom = function() {
// create context menu
var tdMenu = document.createElement('td');
var menu = document.createElement('button');
menu.type = 'button';
dom.menu = menu;
menu.className = 'jsoneditor-contextmenu';
menu.title = 'Click to open the actions menu (Ctrl+M)';
@ -2123,6 +2126,7 @@ Node.prototype._createDomValue = function () {
Node.prototype._createDomExpandButton = function () {
// create expand button
var expand = document.createElement('button');
expand.type = 'button';
if (this._hasChilds()) {
expand.className = this.expanded ? 'jsoneditor-expanded' : 'jsoneditor-collapsed';
expand.title =

View File

@ -52,12 +52,14 @@ function SearchBox (editor, container) {
tbodySearch.appendChild(tr);
var refreshSearch = document.createElement('button');
refreshSearch.type = 'button';
refreshSearch.className = 'jsoneditor-refresh';
td = document.createElement('td');
td.appendChild(refreshSearch);
tr.appendChild(td);
var search = document.createElement('input');
// search.type = 'button';
this.dom.search = search;
search.oninput = function (event) {
searchBox._onDelayedSearch(event);
@ -81,6 +83,7 @@ function SearchBox (editor, container) {
tr.appendChild(td);
var searchNext = document.createElement('button');
searchNext.type = 'button';
searchNext.title = 'Next result (Enter)';
searchNext.className = 'jsoneditor-next';
searchNext.onclick = function () {
@ -91,6 +94,7 @@ function SearchBox (editor, container) {
tr.appendChild(td);
var searchPrevious = document.createElement('button');
searchPrevious.type = 'button';
searchPrevious.title = 'Previous result (Shift+Enter)';
searchPrevious.className = 'jsoneditor-previous';
searchPrevious.onclick = function () {

View File

@ -52,6 +52,7 @@ function appendNodeFactory(Node) {
var tdMenu = document.createElement('td');
dom.tdMenu = tdMenu;
var menu = document.createElement('button');
menu.type = 'button';
menu.className = 'jsoneditor-contextmenu';
menu.title = 'Click to open the actions menu (Ctrl+M)';
dom.menu = menu;

View File

@ -95,6 +95,7 @@ textmode.create = function (container, options) {
// create format button
var buttonFormat = document.createElement('button');
buttonFormat.type = 'button';
buttonFormat.className = 'jsoneditor-format';
buttonFormat.title = 'Format JSON data, with proper indentation and line feeds (Ctrl+\\)';
this.menu.appendChild(buttonFormat);
@ -110,6 +111,7 @@ textmode.create = function (container, options) {
// create compact button
var buttonCompact = document.createElement('button');
buttonCompact.type = 'button';
buttonCompact.className = 'jsoneditor-compact';
buttonCompact.title = 'Compact JSON data, remove all whitespaces (Ctrl+Shift+\\)';
this.menu.appendChild(buttonCompact);

View File

@ -676,6 +676,7 @@ treemode._createFrame = function () {
// create expand all button
var expandAll = document.createElement('button');
expandAll.type = 'button';
expandAll.className = 'jsoneditor-expand-all';
expandAll.title = 'Expand all fields';
expandAll.onclick = function () {
@ -685,6 +686,7 @@ treemode._createFrame = function () {
// create expand all button
var collapseAll = document.createElement('button');
collapseAll.type = 'button';
collapseAll.title = 'Collapse all fields';
collapseAll.className = 'jsoneditor-collapse-all';
collapseAll.onclick = function () {
@ -696,6 +698,7 @@ treemode._createFrame = function () {
if (this.history) {
// create undo button
var undo = document.createElement('button');
undo.type = 'button';
undo.className = 'jsoneditor-undo jsoneditor-separator';
undo.title = 'Undo last action (Ctrl+Z)';
undo.onclick = function () {
@ -706,6 +709,7 @@ treemode._createFrame = function () {
// create redo button
var redo = document.createElement('button');
redo.type = 'button';
redo.className = 'jsoneditor-redo';
redo.title = 'Redo (Ctrl+Shift+Z)';
redo.onclick = function () {