⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 276616 in webkit


Ignore:
Timestamp:
Apr 26, 2021, 2:54:22 PM (5 years ago)
Author:
Nikita Vasilyev
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):

Location:
trunk/Source/WebInspectorUI
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebInspectorUI/ChangeLog

    r276603 r276616  
     12021-04-26  Nikita Vasilyev  <nvasilyev@apple.com>
     2
     3        Web Inspector: Audit Tab: Edits are not committed when leaving edit mode unless you first click into another text field
     4        https://bugs.webkit.org/show_bug.cgi?id=224318
     5        <rdar://problem/76382755>
     6
     7        Reviewed by Devin Rousso.
     8
     9        Save test and setup code when pressing "Done" button. Don't rely on the blur event because it doesn't fire on
     10        the focused element when it's removed from the DOM.
     11
     12        * UserInterface/Models/AuditTestBase.js:
     13        (WI.AuditTestBase.prototype.set setup):
     14        * UserInterface/Models/AuditTestCase.js:
     15        (WI.AuditTestCase.prototype.set test):
     16        Allow setting `test` and `setup` after editing is finished.
     17
     18        * UserInterface/Views/AuditTestCaseContentView.js:
     19        (WI.AuditTestCaseContentView.prototype.layout):
     20        (WI.AuditTestCaseContentView.prototype.saveEditedData):
     21        * UserInterface/Views/AuditTestContentView.js:
     22        (WI.AuditTestContentView.prototype.detached):
     23        Saving test on `detached` saves it when selecting a different test in the navigation sidebar.
     24
     25        (WI.AuditTestContentView.prototype.saveEditedData):
     26        (WI.AuditTestContentView.prototype._createSetupEditor):
     27        (WI.AuditTestContentView.prototype._handleEditingChanged):
     28        (WI.AuditTestContentView):
     29
    1302021-04-26  Devin Rousso  <drousso@apple.com>
    231
  • trunk/Source/WebInspectorUI/UserInterface/Models/AuditTestBase.js

    r266317 r276616  
    122122    {
    123123        console.assert(this.editable);
    124         console.assert(WI.auditManager.editing);
    125124        console.assert(typeof setup === "string", setup);
    126125
  • trunk/Source/WebInspectorUI/UserInterface/Models/AuditTestCase.js

    r266317 r276616  
    101101    {
    102102        console.assert(this.editable);
    103         console.assert(WI.auditManager.editing);
    104103        console.assert(typeof test === "string", test);
    105104
  • trunk/Source/WebInspectorUI/UserInterface/Views/AuditTestCaseContentView.js

    r269359 r276616  
    8282            // Give the rest of the view a chance to load.
    8383            setTimeout(() => {
    84                 let testCodeMirror = WI.CodeMirrorEditor.create(testEditorElement, {
     84                this._testCodeMirror = WI.CodeMirrorEditor.create(testEditorElement, {
    8585                    autoCloseBrackets: true,
    8686                    lineNumbers: true,
    … …  
    9292                    value: this.representedObject.test,
    9393                });
    94 
    95                 if (this.representedObject.editable) {
    96                     testCodeMirror.on("blur", (event) => {
    97                         this.representedObject.test = testCodeMirror.getValue().trim();
    98                     });
    99                 }
    10094            });
    10195            return;
    … …  
    328322    }
    329323
     324    saveEditedData()
     325    {
     326        super.saveEditedData();
     327
     328        this.representedObject.test = this._testCodeMirror.getValue().trim();
     329    }
     330
    330331    showRunningPlaceholder()
    331332    {
  • trunk/Source/WebInspectorUI/UserInterface/Views/AuditTestContentView.js

    r273900 r276616  
    288288
    289289            WI.auditManager.removeEventListener(WI.AuditManager.Event.EditingChanged, this._handleEditingChanged, this);
     290            if (this.representedObject.editable && WI.auditManager.editing)
     291                this.saveEditedData();
    290292        }
    291293
    … …  
    311313
    312314        this._placeholderElement = placeholderElement;
     315    }
     316
     317    saveEditedData()
     318    {
     319        console.assert(this.representedObject.editable, this.representedObject);
     320        this.representedObject.setup = this._setupCodeMirror.getValue().trim();
    313321    }
    314322
    … …  
    495503        // Give the rest of the view a chance to load.
    496504        setTimeout(() => {
    497             let setupCodeMirror = WI.CodeMirrorEditor.create(setupEditorElement, {
     505            this._setupCodeMirror = WI.CodeMirrorEditor.create(setupEditorElement, {
    498506                autoCloseBrackets: true,
    499507                lineNumbers: true,
    … …  
    505513                value: this.representedObject.setup,
    506514            });
    507 
    508             if (this.representedObject.editable) {
    509                 setupCodeMirror.on("blur", (event) => {
    510                     this.representedObject.setup = setupCodeMirror.getValue().trim();
    511                 });
    512             }
    513515        });
    514516
    … …  
    579581        this.needsLayout();
    580582
     583        // We only need to save changes when editing is done. No need to save it after entering the editing mode.
     584        if (!WI.auditManager.editing && this.representedObject.editable)
     585            this.saveEditedData();
     586
    581587        this._updateExportNavigationItems();
    582588    }
Note: See TracChangeset for help on using the changeset viewer.