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 functionality in the body tab #1335

Merged
merged 2 commits into from
Jan 3, 2025

Conversation

iamarjun
Copy link
Contributor

@iamarjun iamarjun commented Jan 3, 2025

This commit addresses and fixes the search functionality in the body (issue reference) tab by:

  • Including all items in the search instead of filtering only body line items.
  • Correcting the index used for search and highlighting.
  • Clearing spans when the query string is not found.
  • Resetting highlight on all items.

These changes ensure that the search works correctly and highlights the correct lines in the body tab.

📷 Screenshots

output.mp4

📄 Context

📝 Changes

📎 Related PR

🚫 Breaking

🛠️ How to test

⏱️ Next steps

This commit fixes the search functionality in the body tab by:

- Including all items in the search instead of filtering only body line items.
- Correcting the index used for search and highlighting.
- Clearing spans when the query string is not found.
- Resetting highlight on all items.

These changes ensure that the search works correctly and highlights the correct lines in the body tab.
@iamarjun iamarjun requested a review from a team as a code owner January 3, 2025 09:48
@iamarjun
Copy link
Contributor Author

iamarjun commented Jan 3, 2025

@@ -320,6 +320,7 @@ internal class TransactionPayloadFragment :
backgroundSpanColor,
foregroundSpanColor,
)
println("listOfSearchQuery: $listOfSearchQuery")
Copy link
Contributor

Choose a reason for hiding this comment

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

@iamarjun, please remove println

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

This commit removes a print statement that was used for debugging purposes. The print statement was located in the `TransactionPayloadFragment` class and was used to print the value of the `listOfSearchQuery` variable.
@iamarjun iamarjun requested a review from A7ak January 3, 2025 10:00
Copy link
Member

@cortinico cortinico left a comment

Choose a reason for hiding this comment

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

Thanks for sending this over

@@ -90,16 +90,16 @@ internal class TransactionBodyAdapter(private val onCopyBodyListener: () -> Unit
foregroundColor: Int,
): List<SearchItemBodyLine> {
val listOfSearchItems = arrayListOf<SearchItemBodyLine>()
items.filterIsInstance<TransactionPayloadItem.BodyLineItem>()
Copy link
Member

Choose a reason for hiding this comment

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

Why have you removed this?

Copy link
Contributor Author

@iamarjun iamarjun Jan 3, 2025

Choose a reason for hiding this comment

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

since TransactionPayloadItem have mutliple types, filtering the BodyLineItem subtype and then indexing them does't really give us the actual index of the item in the whole list. As a result wrong line with wrong search query gets highlighted, also the primary reason for the crash as well

Copy link
Member

Choose a reason for hiding this comment

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

Ahh I understand. Thanks for clarifying 👍

@@ -90,16 +90,16 @@ internal class TransactionBodyAdapter(private val onCopyBodyListener: () -> Unit
foregroundColor: Int,
): List<SearchItemBodyLine> {
val listOfSearchItems = arrayListOf<SearchItemBodyLine>()
items.filterIsInstance<TransactionPayloadItem.BodyLineItem>()
Copy link
Member

Choose a reason for hiding this comment

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

Ahh I understand. Thanks for clarifying 👍

@cortinico cortinico enabled auto-merge (squash) January 3, 2025 13:15
@cortinico cortinico merged commit 66da10c into ChuckerTeam:main Jan 3, 2025
7 checks 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.

3 participants