diff --git a/web_src/js/features/repo-editor.ts b/web_src/js/features/repo-editor.ts index 64d0402d84bc1..d7097787d232d 100644 --- a/web_src/js/features/repo-editor.ts +++ b/web_src/js/features/repo-editor.ts @@ -38,9 +38,6 @@ export function initRepoEditor() { const dropzoneUpload = document.querySelector('.page-content.repository.editor.upload .dropzone'); if (dropzoneUpload) initDropzone(dropzoneUpload); - const editArea = document.querySelector('.page-content.repository.editor textarea#edit_area'); - if (!editArea) return; - for (const el of queryElems(document, '.js-quick-pull-choice-option')) { el.addEventListener('input', () => { if (el.value === 'commit-to-new-branch') { @@ -55,6 +52,7 @@ export function initRepoEditor() { } const filenameInput = document.querySelector('#file-name'); + if (!filenameInput) return; function joinTreePath() { const parts = []; for (const el of document.querySelectorAll('.breadcrumb span.section')) { @@ -144,6 +142,10 @@ export function initRepoEditor() { } }); + // on the upload page, there is no editor(textarea) + const editArea = document.querySelector('.page-content.repository.editor textarea#edit_area'); + if (!editArea) return; + const elForm = document.querySelector('.repository.editor .edit.form'); initEditPreviewTab(elForm);