thegrumpys / odop

Open Design Optimization Platform (ODOP) - Coil spring design app; mechanical springs; compression spring, extension spring, torsion spring
https://www.springdesignsoftware.org
MIT License
4 stars 5 forks source link

Highlight the search term in the linked page #689

Closed 1fifoto closed 2 years ago

1fifoto commented 2 years ago

Highlight the search term in the linked page as illustrated below.

As currently implemented, a Help lookup on the term "AutoSave" produces a "Help lookup for terms 'AutoSave' modal" with "Found 8 matching documents". The first hit is a link to the Help document (entry, article, topic) for AutoSave. If the user clicks on this link, a new browser tab containing the unmodified HTML of that page will open. It is desired that, on this page, every appearance of the search term will be highlighted. This example shows such highlighting as generated by the "Find on page" (ctrl-f) feature of the MS Edge browser. Alternate implementations with similar but not necessarily identical results should be considered.

image

1fifoto commented 2 years ago

Checked in first pass of 689 and merged into master.

Screen Shot 2022-05-16 at 4 42 31 PM

But there is a nasty problem that I can't understand what is going wrong. Multiple searches (of the same word?) cause the search results to become garbled and longer & longer.

Screen Shot 2022-05-16 at 5 10 21 PM

And sometimes the server gets messed up and generates an error. I have no idea what is going wrong and could use your help isolating the root cause.

Screen Shot 2022-05-16 at 5 10 44 PM
grumpyinca commented 2 years ago

Observations on the problem noted in the previous comment ...

I seem to be able to get repeatable results when I restart the server, otherwise, there seems to be a random component. Operation of the highlighting in the Help topic seems correct and stable. The blurb of the first lookup after server re-start appears correct. The blurb of the second lookup appears to have significant problems. Perhaps it is both first and second terms that drive the blurb contents and get highlighted on the second use of Help Lookup. Also, I observe semi-random corruption in the blurb. It almost seems to be inserted snippets of JavaScript memory contents ... a lot of % signs followed by dights, color codes.

These observations lead to a bit of speculation. Perhaps the problem is on the server side. Perhaps something is not getting initialized properly on subsequent invocations of the server side of the Help Lookup sequence. The problem seems to be blurb related and at least not directly related to the highlighting of terms in the Help topic. What were the recent server-side changes in that blurb area ? How is it possible that un-initialized memory is getting mapped into the blurb content ?

1fifoto commented 2 years ago

Neede to clone lunr page info so that updates are no saved back into the page info, change from

let pageMatch = lunr_pages.filter((page) => page.href === hit.ref)[0];

to

let pageMatch = JSON.parse(JSON.stringify(lunr_pages.filter((page) => page.href === hit.ref)[0]));

Merged into master, waiting on closing until more testing by Mike.

1fifoto commented 2 years ago

Merged into master again, closing

grumpyinca commented 2 years ago

I observed a problem with repeats of the same sentence in the blurb. It is possible that the May 17 change did not fully repair all of the (potentially multiple) symptoms that were being observed at that time. Re-opening this issue.

To recreate the problem:

  1. Perform a Help Lookup on "+ODOP +version"
  2. Observe "Found 7 matching documents"
  3. Examine the blurb associated with the "Terminology" topic. Specifically do a "Find on Page" for "Help : About also displays".
  4. Observe that the sentence containing these words is repeated 6 times.
  5. Observe that the sentence containing these words appears only once in client/docs/Help/terminology.md

I have the notion that the blurb should contain no more copies of the same sentence than appear in the original document file. In this case, the sentence appears once in the original .md file but appears 6 times in the blurb. So, while perhaps I am missing something, I think that this is enough of a problem to reopen this issue.

1fifoto commented 2 years ago

The above comment has been fixed and released to master, closing