Skip to content

[dataquery] fixes oversized table head element - #11087

Open
marandmart wants to merge 8 commits into
aces:mainfrom
marandmart:dataquery_scrolling_query
Open

marandmart wants to merge 8 commits into
aces:mainfrom
marandmart:dataquery_scrolling_query

Conversation

@marandmart

Copy link
Copy Markdown
Contributor

Brief summary of changes

  • Fixes issue where field descriptions could render raw HTML inside .
  • Adds min-width to td/th and max-height to headers in the table rendering to prevent excessively tall table heads when displaying long text.

Testing instructions

  1. Create a query with fields that have raw HTML in their descriptions and very long text strings.
  2. Render the dataquery table.
  3. Verify the HTML tags are safely escaped and not rendered as active HTML.
  4. Verify the table header layout remains constrained (doesn't stretch vertically).

Link to related issue

@github-actions github-actions Bot added Language: Javascript PR or issue that update Javascript code Module: dataquery PR or issue related to (new) dataquery module labels Jul 28, 2026
@HenriRabalais

Copy link
Copy Markdown
Collaborator

@adamdaudrich can you take a look at this since you created the issue?

@adamdaudrich

Copy link
Copy Markdown
Contributor

LGTM
The"real world" usecase was a project in CBIGR where field names came from the following pipeline:
redcap-->redcap2linst-->DQT.
So the problem was how their redcap was setup and how the fields got translated to linst. We used a php library function to strip html out, but still...
if you have cbig repo permission, check instrument 'abasiii_521', the static ones.

@HenriRabalais

Copy link
Copy Markdown
Collaborator

Ok, I'll do a code review in the coming days!

@HenriRabalais HenriRabalais left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

hey @marandmart! took a proper look, mostly small stuff but I'd like to sort a few things before approving:

  1. the stripHTML is going into getDictionaryDescription, which is used in 6 places (fielddisplay, welcome, viewdata, definefields), not just the table header. so this strips html from descriptions everywhere now… is that intentional, or should it be scoped to just the header in viewdata? I could see it being an improvement across the board but wanted to check!
  2. for the label type going to string | ReactNode… does the label actually need to be a ReactNode? could we keep it a string and handle the header sizing on the th directly instead of wrapping the value in a <div>? and if it does need to change, ReactNode already includes string, so the union can just be ReactNode.
  3. the <style> block is injected inline in the render, and there's no css file in the dataquery module yet. could we move it into a proper .css file and import it at the top? (the way Filter.tsx does with Filter.css)
  4. the min-width: 150px is on both th and td, so it widens every column, not just the header, which'll add horizontal scroll on wider result sets. was that intended?

nothing major, just want to make sure we're not stripping html or forcing column widths in more places than we mean to! let me know 🙂

@marandmart

Copy link
Copy Markdown
Contributor Author

Hi @HenriRabalais!

  1. No, not intentional. I missed that that method is being used in other parts of the code. Should I change it to make it apply only to the viewdata part or do you think it makes sense to leave it in that method?
  2. I tried applying the styles directly to the th to limit its’ height but they weren’t working correctly. The workaround I found was to wrap the text content around a div and applying the styles to the div and then the solution worked.
  3. Done!
  4. Yes! Overall I thought it looked slightly better to apply a min-width that makes the columns’ width more consistent with each other. But I guess its more of preference, if you don't think it necessary I can remove that.

@HenriRabalais

HenriRabalais commented Aug 31, 2026 •

Copy link
Copy Markdown
Collaborator

thanks for going through all of those!

  1. i checked all six call sites and none of them render the description as html, so stripping it inside getDictionaryDescription is safe to leave where it is. fielddisplay, definefields and the two formatHeader cases all render it as plain text, which means any html in a description is currently showing up to the user as literal tags. the other two in welcome.tsx are the search filter, and stripping helps there too since searching for something like "span" won't match the markup anymore.

one thing i did notice though, stripHTML builds a whole document with new DOMParser() on every call, and welcome.tsx calls it in a loop over every field while filtering. on a big dictionary that's a document per field per keystroke. could we do the regex first and only fall back to DOMParser when it doesn't come out clean?

  1. got it, that makes sense as a workaround, happy to keep the div.

(4). let's drop it. I think the .header-text clamp is what actually fixes the oversized header, and the min-width widens every column, which brings back the horizontal scroll on wider result sets. also worth noting a column takes the widest of the th and the td either way, so having it on both is redundant.

rest looks good to me, nice work on moving the css out into its own file 🙂

@marandmart

marandmart commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor Author

(1). I tried using a regex to strip HTML from the string, but I couldn’t come up with a reliable check for when we should fall back to the DOMParser. I also found several edge cases where the regex wouldn’t correctly strip the tags. In the end, I settled on a simpler approach: check for an obvious tell that the string contains HTML tags, and if it doesn't just return the string as is, else leave it to the DOMParser. This way most cases should just skip the DOMParser

(4). removed

@HenriRabalais HenriRabalais left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

hey @marandmart! thanks for sorting the DOMParser one, that's exactly what I was after 🙂 a description with no tags never touches the parser now, so the filter loop in welcome stays cheap even on a big dictionary.

one small thing that doesn't block: label: string | ReactNode can just be ReactNode since it already includes string.

@HenriRabalais

Copy link
Copy Markdown
Collaborator

@marandmart

this conflicts with main now, could you merge main in? then it should be good to go

@marandmart

Copy link
Copy Markdown
Contributor Author

@HenriRabalais done!

@HenriRabalais

Copy link
Copy Markdown
Collaborator

hey @marandmart this conflicts with main again, could you merge main in when you have the time?

@marandmart

Copy link
Copy Markdown
Contributor Author

@HenriRabalais fixed! I had to make a small change to the fix applied to keep inline with the updates from the conflict to DataTable.d.ts. So moved the div with the header-text class from the view-data.tsx and into the DataTable.js file itself to keep the Field type with the field.label type as string working. You can see the change by checking out the last commit

HenriRabalais added a commit to HenriRabalais/Loris that referenced this pull request Dec 4, 2026
Net change of aces/Loris PR aces#11087 at de05afc, ported onto the 29.0 DataTable.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Language: Javascript PR or issue that update Javascript code Module: dataquery PR or issue related to (new) dataquery module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[dataquery] scrolling query

3 participants