Skip to content

Commit

Permalink
remove listener to copy over milestone fields (#3162)
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielRyanSmith authored Jul 16, 2023
1 parent f0365f6 commit c27f3c6
Showing 1 changed file with 2 additions and 34 deletions.
36 changes: 2 additions & 34 deletions client-src/elements/chromedash-guide-stage-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ export class ChromedashGuideStagePage extends LitElement {
this.handleFormSubmit(event, hiddenTokenField);
});

this.addMiscEventListeners();
this.miscSetup();
setupScrollToHash(this);
}

Expand All @@ -135,45 +135,13 @@ export class ChromedashGuideStagePage extends LitElement {
});
}

addMiscEventListeners() {
const fields = this.shadowRoot.querySelectorAll('input, textarea');
for (let i = 0; i < fields.length; ++i) {
fields[i].addEventListener('input', (e) => {
e.target.classList.add('interacted');
});
}

miscSetup() {
// Allow editing if there was already a value specified in this
// deprecated field.
const timelineField = this.shadowRoot.querySelector('#id_experiment_timeline');
if (timelineField && timelineField.value) {
timelineField.disabled = '';
}

// Copy field SRC to DST if SRC is edited and DST was empty and
// has not been edited.
const COPY_ON_EDIT = [
['dt_milestone_desktop_start', 'dt_milestone_android_start'],
['dt_milestone_desktop_start', 'dt_milestone_webview_start'],
// Don't autofill dt_milestone_ios_start because it is rare.
['ot_milestone_desktop_start', 'ot_milestone_android_start'],
['ot_milestone_desktop_end', 'ot_milestone_android_end'],
['ot_milestone_desktop_start', 'ot_milestone_webview_start'],
['ot_milestone_desktop_end', 'ot_milestone_webview_end'],
];

for (const [srcId, dstId] of COPY_ON_EDIT) {
const srcEl = this.shadowRoot.querySelector('#id_' + srcId);
const dstEl = this.shadowRoot.querySelector('#id_' + dstId);
if (srcEl && dstEl && srcEl.value == dstEl.value) {
srcEl.addEventListener('input', () => {
if (!dstEl.classList.contains('interacted')) {
dstEl.value = srcEl.value;
dstEl.classList.add('copied');
}
});
}
}
}

handleCancelClick() {
Expand Down

0 comments on commit c27f3c6

Please sign in to comment.