diff --git a/services/web/frontend/js/features/file-tree/controllers/file-tree-controller.js b/services/web/frontend/js/features/file-tree/controllers/file-tree-controller.js index 73cf3313f5..ebd5b90d48 100644 --- a/services/web/frontend/js/features/file-tree/controllers/file-tree-controller.js +++ b/services/web/frontend/js/features/file-tree/controllers/file-tree-controller.js @@ -25,6 +25,10 @@ App.controller( ) }) + $scope.$on('file-tree.reselectDoc', (ev, docId) => { + window.dispatchEvent(new CustomEvent('editor.openDoc', { detail: docId })) + }) + // Set isConnected to true if: // - connection state is 'ready', OR // - connection state is 'waitingCountdown' and reconnection_countdown is null diff --git a/services/web/frontend/js/features/pdf-preview/components/pdf-synctex-controls.js b/services/web/frontend/js/features/pdf-preview/components/pdf-synctex-controls.js index fffdd125a4..312ec1ac54 100644 --- a/services/web/frontend/js/features/pdf-preview/components/pdf-synctex-controls.js +++ b/services/web/frontend/js/features/pdf-preview/components/pdf-synctex-controls.js @@ -23,7 +23,6 @@ function GoToCodeButton({ syncToCode, syncToCodeInFlight, isDetachLayout, - hasSingleSelectedDoc, }) { const { t } = useTranslation() const tooltipPlacement = isDetachLayout ? 'bottom' : 'right' @@ -51,7 +50,7 @@ function GoToCodeButton({ bsStyle="default" bsSize="xs" onClick={() => syncToCode(position, 72)} - disabled={syncToCodeInFlight || !hasSingleSelectedDoc} + disabled={syncToCodeInFlight} className={buttonClasses} aria-label={t('go_to_pdf_location_in_code')} > @@ -367,7 +366,6 @@ function PdfSynctexControls() { syncToCode={syncToCode} syncToCodeInFlight={syncToCodeInFlight} isDetachLayout - hasSingleSelectedDoc={hasSingleSelectedDoc} /> ) @@ -385,7 +383,6 @@ function PdfSynctexControls() { position={position} syncToCode={syncToCode} syncToCodeInFlight={syncToCodeInFlight} - hasSingleSelectedDoc={hasSingleSelectedDoc} /> ) @@ -399,7 +396,6 @@ GoToCodeButton.propTypes = { position: PropTypes.object.isRequired, syncToCode: PropTypes.func.isRequired, syncToCodeInFlight: PropTypes.bool.isRequired, - hasSingleSelectedDoc: PropTypes.bool.isRequired, } GoToPdfButton.propTypes = { diff --git a/services/web/frontend/js/ide/editor/EditorManager.js b/services/web/frontend/js/ide/editor/EditorManager.js index 9e5da19401..291d37c6fc 100644 --- a/services/web/frontend/js/ide/editor/EditorManager.js +++ b/services/web/frontend/js/ide/editor/EditorManager.js @@ -225,6 +225,7 @@ export default EditorManager = (function () { if (doc.id === this.$scope.editor.open_doc_id && !options.forceReopen) { // automatically update the file tree whenever the file is opened this.ide.fileTreeManager.selectEntity(doc) + this.$scope.$broadcast('file-tree.reselectDoc', doc.id) this.$scope.$apply(() => { return done(false) }) diff --git a/services/web/test/frontend/components/pdf-preview/pdf-synctex-controls.spec.tsx b/services/web/test/frontend/components/pdf-preview/pdf-synctex-controls.spec.tsx index 5a6fecf0b0..d0f4a95770 100644 --- a/services/web/test/frontend/components/pdf-preview/pdf-synctex-controls.spec.tsx +++ b/services/web/test/frontend/components/pdf-preview/pdf-synctex-controls.spec.tsx @@ -132,10 +132,6 @@ describe('', function () { cy.get('body') .findByRole('button', { name: 'Go to code location in PDF' }) .should('be.disabled') - - cy.get('body') - .findByRole('button', { name: /^Go to PDF location in code/ }) - .should('be.disabled') }) it('disables button when a file is selected', function () { @@ -152,10 +148,6 @@ describe('', function () { cy.get('body') .findByRole('button', { name: 'Go to code location in PDF' }) .should('be.disabled') - - cy.get('body') - .findByRole('button', { name: /^Go to PDF location in code/ }) - .should('be.disabled') }) describe('with detacher role', function () { @@ -285,16 +277,9 @@ describe('', function () { cy.wait('@compile') - cy.get('body') - .findByRole('button', { name: /^Go to PDF location in code/ }) - .should('be.disabled') - .then(() => { - sysendTestHelper.receiveMessage({ - role: 'detached', - event: 'state-has-single-selected-doc', - data: { value: true }, - }) - }) + cy.get('body').findByRole('button', { + name: /^Go to PDF location in code/, + }) cy.get('body') .findByRole('button', { name: /^Go to PDF location in code/ })