Expand Table button shows wrong table

I recently created a post that contained a couple of tables. The first table looked like this:

Drug Example prescription(s) Feature(s)
abacavir 300 mg mg by mouth twice daily
600 mg by mouth once daily
Multiple templates for the same drug
abacavir / dolutegravir / lamivudine 1 tablet by mouth daily Combination drug
levonorgestrel One tablet by mouth as soon as possible within 72 hours of unprotected sexual intercourse or suspected contraceptive failure Free text dosing instructions
paracetamol 500 mg every 6 hours as needed for pain As needed dosing

There was some intervening text …

with

  • list
  • and
  • other
  • stuff

…and then another (large) table like this:

concept drug template
Abacavir Abacavir 300 mg tablet
{
  dosingType: "org.openmrs.SimpleDosingInstructions",
  instructions: {
    dose: 300,
    doseUnits: "161553AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", /* mg */
    route: "160240AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", /* oral */
    frequency: "160858AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", /* twice daily */
  }
Abacavir Abacavir 300 mg tablet
{
  dosingType: "org.openmrs.SimpleDosingInstructions",
  instructions: {
    dose: 600,
    doseUnits: "161553AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", /* mg */
    route: "160240AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", /* oral */
    frequency: "160862AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", /* once daily */
  }
}
Abacavir / dolutegravir / lamivudine Abacavir/dolutegravir/lamivudine 600/50/300 tablet
{
  dosingType: "org.openmrs.SimpleDosingInstructions",
  instructions: {
    dose: 1,
    doseUnits: "1513AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", /* tablet */
    route: "160240AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", /* oral */
    frequency: "160862AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", /* once daily */
  }
}
Levonorgestrel Levonorgestrel 1.5 mg tablet
{
  dosingType: "org.openmrs.FreeTextDosingInstructions",
  instructions: {
    text: "One tablet by mouth as soon as possible within 72 hours of unprotected sexual intercourse or suspected contraceptive failure"
  }
}
Paracetamol Paracetamol 500 mg tablet
{
  dosingType: "org.openmrs.SimpleDosingInstructions",
  instructions: {
    dose: 500,
    doseUnits: "161553AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", /* mg */
    route: "160240AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", /* oral */
    frequency: "162249AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", /* every 6 hours */
    asNeeded: true,
    asNeededCondition: "pain"
  }
}

The JSON templates got cropped without the ability to horizontally scroll them or the table. Fortunately, when hovering over the second table, the spiffy new “Expand Table” button appeared. Unfortunately, when I clicked on the button to expand the second table, it showed an expanded view of the first table. So, I’ve copied the tables into a post here to see if I can recreate the problem on meta.

Sure enough. It looks like the same bug is happening here. Perhaps the problem is because the first table is done with markdown and the second table is done using HTML (in order to embed JSON with syntax highlighting). :confused:

3 Likes

Oh I can see the bug here:

We are doing a naive query selector here, so it is always picking the first table in the post. Instead it should search for the first table after the button that was clicked.

We will get this sorted some time in the next month, thanks for raising.

7 Likes

This has been fixed per DEV: Update expand-table table query by janzenisaac · Pull Request #17347 · discourse/discourse · GitHub

The expected table will now open :slight_smile: Thanks for raising this!

4 Likes