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

Truncate Dataverse Description Text #9265

Conversation

qqmyers
Copy link
Member

@qqmyers qqmyers commented Jan 5, 2023

What this PR does / why we need it:

This was developed as a possible alternative to #9222 . It makes changes to the contentTruncate function to allow it to be used in both the dataset and dataverse pages.

It also adds some possible fixes/improvements:

  • The Collapse Description [+] button shows a + sign like the Read full Description [+] - I've changed that to use a minus sign Collapse Description [-] - I assume that was just a typo.
  • The current code only truncates the first dataset description when there is more than one. Both would be displayed above the fold so I changed the selector to truncate any description that needs it.
  • The original code calls DatasetPage.datasetVersionUI.description.datasetFieldType.localeTitle multiple times - I'm guessing one cset and reuse of that variable is more efficient.

The one thing that may be different is exactly where the page scrolls to when one re-collapses the description on a dataset page. The old code would have scrolled to the top of all descriptions whereas it will now scroll to the top of the description being collapsed. Since the old code would only collapse the first one, this should be a matter of a few pixels at most. (FWIW - the technical reason is that the truncSelector is reused in the contentTruncate function and my change means truncSelector points to the specific dataset description rather than the top of the element containing all descriptions. This could probably be fixed if desired - not sure it is worth it or that scrolling to the top of all descriptions makes sense now that all descriptions get truncated.)

Which issue(s) this PR closes:

Closes #1249

Special notes for your reviewer:

Suggestions on how to test this:

Does this PR introduce a user interface change? If mockups are available, please link/include them here:

Is there a release notes update needed for this change?:

Additional documentation:

Fix + sign in collapse
Fix only truncate first description
Use cset to avoid duplication (efficiency?)
@ant-reyes
Copy link

Hello @qqmyers!

I tried testing this out, but it seems like it did not work. While trying to dig around to see what the problem was, I noticed that that while I was on a Dataverse page, in Sources Tab of Chrome Developer Tools -> javax.faces.resource -> js -> dv_rebind_bootstrap_ui.js.xhtml?version=5.12.1 was not the same as dv_rebind_bootstrap_ui.js in the source code.

Screen Shot 2023-01-17 at 10 02 43 AM

I am not sure why this is the case, but in dataverse_template.xhtml,
I changed line 76 from: <script src="#{resource['js/dv_rebind_bootstrap_ui.js']}?version=#{settingsWrapper.appVersion}"></script>
to: <script src="#{resource['js/dv_rebind_bootstrap_ui.js']}"></script>
which removed the '?version=5.12.1' from dv_rebind_bootstrap_ui.js and then contentTruncate worked correctly.

To my understanding, it seems like the wrong version of dv_rebind_bootstrap_ui.js is being called in dataverse_template.xhtml?

@qqmyers
Copy link
Member Author

qqmyers commented Jan 17, 2023

I think this is a caching issue in the browser. The idea of putting the ?version=X at the end avoids it for non-developers - when v5.13 comes out, the browser will auto-update it in users browser. Unfortunately, when we make a change to the script in development and the version doesn't change, your browser doesn't know to update. The work-around is to open that script in a separate pane and do the SHIFT-refresh to force the browser to get a new copy. After that the Dataverse pages will get the updated version.

@ant-reyes
Copy link

Got it, thanks! That fixed the issue.

ant-reyes pushed a commit to ant-reyes/dataverse that referenced this pull request Jan 24, 2023
I added changes suggested by @qqmyers from IQSS#9265 as well as a small change to prevent a horizontal scrollbar from appearing.
@pdurbin
Copy link
Member

pdurbin commented Feb 10, 2023

@qqmyers thanks for showing the way to me and @ar062800

I'm going to go ahead and close this PR now that I've approved his:

@pdurbin pdurbin closed this Feb 10, 2023
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.

Dataverse - Description text truncated
3 participants