Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove listener to copy over OT milestone fields #3162

Merged
merged 1 commit into from
Jul 16, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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