- Revision
- 276616
- Author
- nvasil...@apple.com
- Date
- 2021-04-26 14:54:22 -0700 (Mon, 26 Apr 2021)
Log Message
Web Inspector: Audit Tab: Edits are not committed when leaving edit mode unless you first click into another text field
https://bugs.webkit.org/show_bug.cgi?id=224318
<rdar://problem/76382755>
Reviewed by Devin Rousso.
Save test and setup code when pressing "Done" button. Don't rely on the blur event because it doesn't fire on
the focused element when it's removed from the DOM.
* UserInterface/Models/AuditTestBase.js:
(WI.AuditTestBase.prototype.set setup):
* UserInterface/Models/AuditTestCase.js:
(WI.AuditTestCase.prototype.set test):
Allow setting `test` and `setup` after editing is finished.
* UserInterface/Views/AuditTestCaseContentView.js:
(WI.AuditTestCaseContentView.prototype.layout):
(WI.AuditTestCaseContentView.prototype.saveEditedData):
* UserInterface/Views/AuditTestContentView.js:
(WI.AuditTestContentView.prototype.detached):
Saving test on `detached` saves it when selecting a different test in the navigation sidebar.
(WI.AuditTestContentView.prototype.saveEditedData):
(WI.AuditTestContentView.prototype._createSetupEditor):
(WI.AuditTestContentView.prototype._handleEditingChanged):
(WI.AuditTestContentView):
Modified Paths
Diff
Modified: trunk/Source/WebInspectorUI/ChangeLog (276615 => 276616)
--- trunk/Source/WebInspectorUI/ChangeLog 2021-04-26 21:44:16 UTC (rev 276615)
+++ trunk/Source/WebInspectorUI/ChangeLog 2021-04-26 21:54:22 UTC (rev 276616)
@@ -1,3 +1,32 @@
+2021-04-26 Nikita Vasilyev <nvasil...@apple.com>
+
+ Web Inspector: Audit Tab: Edits are not committed when leaving edit mode unless you first click into another text field
+ https://bugs.webkit.org/show_bug.cgi?id=224318
+ <rdar://problem/76382755>
+
+ Reviewed by Devin Rousso.
+
+ Save test and setup code when pressing "Done" button. Don't rely on the blur event because it doesn't fire on
+ the focused element when it's removed from the DOM.
+
+ * UserInterface/Models/AuditTestBase.js:
+ (WI.AuditTestBase.prototype.set setup):
+ * UserInterface/Models/AuditTestCase.js:
+ (WI.AuditTestCase.prototype.set test):
+ Allow setting `test` and `setup` after editing is finished.
+
+ * UserInterface/Views/AuditTestCaseContentView.js:
+ (WI.AuditTestCaseContentView.prototype.layout):
+ (WI.AuditTestCaseContentView.prototype.saveEditedData):
+ * UserInterface/Views/AuditTestContentView.js:
+ (WI.AuditTestContentView.prototype.detached):
+ Saving test on `detached` saves it when selecting a different test in the navigation sidebar.
+
+ (WI.AuditTestContentView.prototype.saveEditedData):
+ (WI.AuditTestContentView.prototype._createSetupEditor):
+ (WI.AuditTestContentView.prototype._handleEditingChanged):
+ (WI.AuditTestContentView):
+
2021-04-26 Devin Rousso <drou...@apple.com>
Web Inspector: Audit: Uncaught Exception: Failed to execute 'delete' on 'IDBObjectStore': The parameter is not a valid key range.
Modified: trunk/Source/WebInspectorUI/UserInterface/Models/AuditTestBase.js (276615 => 276616)
--- trunk/Source/WebInspectorUI/UserInterface/Models/AuditTestBase.js 2021-04-26 21:44:16 UTC (rev 276615)
+++ trunk/Source/WebInspectorUI/UserInterface/Models/AuditTestBase.js 2021-04-26 21:54:22 UTC (rev 276616)
@@ -121,7 +121,6 @@
set setup(setup)
{
console.assert(this.editable);
- console.assert(WI.auditManager.editing);
console.assert(typeof setup === "string", setup);
if (setup === this._setup)
Modified: trunk/Source/WebInspectorUI/UserInterface/Models/AuditTestCase.js (276615 => 276616)
--- trunk/Source/WebInspectorUI/UserInterface/Models/AuditTestCase.js 2021-04-26 21:44:16 UTC (rev 276615)
+++ trunk/Source/WebInspectorUI/UserInterface/Models/AuditTestCase.js 2021-04-26 21:54:22 UTC (rev 276616)
@@ -100,7 +100,6 @@
set test(test)
{
console.assert(this.editable);
- console.assert(WI.auditManager.editing);
console.assert(typeof test === "string", test);
if (test === this._test)
Modified: trunk/Source/WebInspectorUI/UserInterface/Views/AuditTestCaseContentView.js (276615 => 276616)
--- trunk/Source/WebInspectorUI/UserInterface/Views/AuditTestCaseContentView.js 2021-04-26 21:44:16 UTC (rev 276615)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/AuditTestCaseContentView.js 2021-04-26 21:54:22 UTC (rev 276616)
@@ -81,7 +81,7 @@
// Give the rest of the view a chance to load.
setTimeout(() => {
- let testCodeMirror = WI.CodeMirrorEditor.create(testEditorElement, {
+ this._testCodeMirror = WI.CodeMirrorEditor.create(testEditorElement, {
autoCloseBrackets: true,
lineNumbers: true,
lineWrapping: true,
@@ -91,12 +91,6 @@
styleSelectedText: true,
value: this.representedObject.test,
});
-
- if (this.representedObject.editable) {
- testCodeMirror.on("blur", (event) => {
- this.representedObject.test = testCodeMirror.getValue().trim();
- });
- }
});
return;
}
@@ -327,6 +321,13 @@
this._resultDataErrorsContainer = null;
}
+ saveEditedData()
+ {
+ super.saveEditedData();
+
+ this.representedObject.test = this._testCodeMirror.getValue().trim();
+ }
+
showRunningPlaceholder()
{
if (!this.placeholderElement || !this.placeholderElement.__placeholderRunning) {
Modified: trunk/Source/WebInspectorUI/UserInterface/Views/AuditTestContentView.js (276615 => 276616)
--- trunk/Source/WebInspectorUI/UserInterface/Views/AuditTestContentView.js 2021-04-26 21:44:16 UTC (rev 276615)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/AuditTestContentView.js 2021-04-26 21:54:22 UTC (rev 276616)
@@ -287,6 +287,8 @@
this.representedObject.removeEventListener(WI.AuditTestBase.Event.SupportedChanged, this._handleTestSupportedChanged, this);
WI.auditManager.removeEventListener(WI.AuditManager.Event.EditingChanged, this._handleEditingChanged, this);
+ if (this.representedObject.editable && WI.auditManager.editing)
+ this.saveEditedData();
}
super.detached();
@@ -312,6 +314,12 @@
this._placeholderElement = placeholderElement;
}
+ saveEditedData()
+ {
+ console.assert(this.representedObject.editable, this.representedObject);
+ this.representedObject.setup = this._setupCodeMirror.getValue().trim();
+ }
+
showRunningPlaceholder()
{
// Overridden by sub-classes.
@@ -494,7 +502,7 @@
// Give the rest of the view a chance to load.
setTimeout(() => {
- let setupCodeMirror = WI.CodeMirrorEditor.create(setupEditorElement, {
+ this._setupCodeMirror = WI.CodeMirrorEditor.create(setupEditorElement, {
autoCloseBrackets: true,
lineNumbers: true,
lineWrapping: true,
@@ -504,12 +512,6 @@
styleSelectedText: true,
value: this.representedObject.setup,
});
-
- if (this.representedObject.editable) {
- setupCodeMirror.on("blur", (event) => {
- this.representedObject.setup = setupCodeMirror.getValue().trim();
- });
- }
});
this._setupEditorElement.parentNode.replaceChild(setupEditorElement, this._setupEditorElement);
@@ -578,6 +580,10 @@
{
this.needsLayout();
+ // We only need to save changes when editing is done. No need to save it after entering the editing mode.
+ if (!WI.auditManager.editing && this.representedObject.editable)
+ this.saveEditedData();
+
this._updateExportNavigationItems();
}
};