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

fix citation key render in reader #2922

Closed

Conversation

windingwind
Copy link

@@ -866,23 +866,15 @@ export class BetterBibTeX {
// onRender: ({ body, item, editable, tabType }) => {
onRender: ({ body, item, setSectionSummary }) => {
const citekey = item.getField('citationKey')
const textbox = body.ownerDocument.getElementById('better-bibtex-citation-key')
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will always return the first matched element, which is the one in the library. Thus, the citation key in readers will never be rendered.

body.style.display = 'flex'
// const was = textbox.dataset.itemid || '<node>'
textbox.value = citekey || ''
textbox.dataset.itemid = citekey ? `${item.id}` : ''
setSectionSummary(citekey || '')
},
onInit: ({ body, refresh }) => {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The custom section will always be automatically re-rendered on item change. Not sure if I understand correctly, but I think this call to refresh is unnecessary unless you need it to re-render even when the item is not changed.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The citation key can change when the formula changes and the key is refreshed, or when it is bumped out of the way by a freshly pinned key on another item, both of which happen without a change to the item whose key is changing.

Copy link
Author

@windingwind windingwind Jul 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, that makes sense. Sorry I'm not familiar with the BBT code.

Would you like me to update the PR for merging? (I suppose the main branch is already updated and we can close this PR?)

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I've already made the other change, thanks for that btw. I'm going to be bumping into more of these one-main-window assumptions, good to know what the fix is.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, that makes sense. Sorry I'm not familiar with the BBT code.

Absolutely no worries, BBT has gotten quite complex over the years.

@retorquere retorquere closed this Jul 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants