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 search highlights disappearing when opening entity previews #3093

Merged
merged 2 commits into from
May 30, 2023

Conversation

tillprochaska
Copy link
Contributor

When searching, we keep the search results in the Redux store in a structure similar to the following:

{
  "entities": {
    "abc123": {
      "id": "abc123",
      "schema": "Company",
      "highlight": "<em>Twitter</em> is an online social media and social networking service."
    }
  },
  "results": {
    "entities?filter:schemata:Company&highlight=true&limit=30&q=twitter": {
      "total": 1,
      "page": 1,
      "results": ["abc123"]
    }
  }
}

After clicking on one of the search results, we load detailed entity data and use the detailed data to replace the (partial) entity data from the initial search request. However, the response from the second request does not contain the search highlight, i.e. the highlight is removed from the state when loading additional entity data.

We can work around this by merging data instead of replacing data. It does still feel a bit like a hacky workaround, but a proper solution would require making significant changes to our state management solution (probably replacing it with an off-the-shelf solution).

Fix #2268

When searching, we keep the search results in the Redux store in a structure similar to the following:

```json
{
  "entities": {
    "abc123": {
      "id": "abc123",
      "schema": "Company",
      "highlight": "<em>Twitter</em> is an online social media and social networking service."
    }
  },
  "results": {
    "entities?filter:schemata:Company&highlight=true&limit=30&q=twitter": {
      "total": 1,
      "page": 1,
      "results": ["abc123"]
    }
  }
}
```

After clicking on one of the search results, we load detailed entity data and use the detailed data to replace the (partial) entity data from the initial search request. However, the response from the second request does not contain the search highlight, i.e. the highlight is removed from the state when loading additional entity data.

We can work around this by merging data instead of replacing data. It does still feel a bit like a hacky workaround, but a proper solution would require making significant changes to our state management solution (probably replacing it with an off-the-shelf solution).

Fix #2268
When selecting/clicking on a result on a search results page, we change the background color to dark blue.
@tillprochaska tillprochaska force-pushed the fix/2268-search-highlight-disappears branch from 90b29f0 to 749c943 Compare May 24, 2023 17:07
@tillprochaska tillprochaska changed the title Fix/2268 search highlight disappears Fix search highlights disappearing when opening entity previews May 24, 2023
@@ -47,7 +47,7 @@ $aleph-sidebar-width: $aleph-grid-size * 35;
$aleph-sidebar-sm-width: $aleph-grid-size * 20;
$aleph-sidepane-md-width: $aleph-grid-size * 27;

$aleph-text-highlight-color: yellow;
$aleph-text-highlight-color: rgba($gold5, 0.5);
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this really $gold5 or is it actually $dirtyMustard? Joking.

ui/src/reducers/util.js Show resolved Hide resolved
@tillprochaska tillprochaska merged commit c1f8000 into develop May 30, 2023
1 check passed
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.

Highlight text in search results dissappears when opening the result
2 participants