Merge pull request #7323 from overleaf/ta-synctex-disable-multi-one-way

Don't Disable Synctex PDF-to-Code Button

GitOrigin-RevId: 90328e0fea8cb5358217ce866839f5e1a4a73b94
This commit is contained in:
Timothée Alby 2022-04-12 12:44:20 +02:00 committed by Copybot
parent 04bc5103ea
commit a110c4d7bd
4 changed files with 9 additions and 23 deletions

View file

@ -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

View file

@ -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 = {

View file

@ -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)
})

View file

@ -132,10 +132,6 @@ describe('<PdfSynctexControls/>', 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('<PdfSynctexControls/>', 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,15 +277,8 @@ describe('<PdfSynctexControls/>', 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')