[PR #5435] [MERGED] feat(common): add erase response functionality with keybindings #5204

Closed
opened 2026-03-17 02:40:23 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/hoppscotch/hoppscotch/pull/5435
Author: @12fahed
Created: 10/3/2025
Status: Merged
Merged: 11/26/2025
Merged by: @jamesgeorge007

Base: nextHead: feat/clear-response


📝 Commits (10+)

  • 842a139 feat: clear response button for html & json renderer
  • 6cd3980 chore: disable clear response for examples
  • 3ad9021 refactor: relocate clear response (erase) action button to more menu for JSON Renderer
  • fd527b1 feat: add "clear response" option in "more option" inside tippy menu for RAW renderer
  • bee549f refactor: move "clear response" button to tippy more option for HTML renderer
  • cdfb4d6 feat: add "clear response" option in "more option" inside tippy menu for XML renderer
  • 43687f4 chore: add clear response for image lense
  • 07a2e00 chore: disable clear response for saved example
  • 2806233 chore: add clear response for Audio lense
  • 6bbad10 chore: add clear response for PDF lense

📊 Changes

11 files changed (+326 additions, -28 deletions)

View changed files

📝 packages/hoppscotch-common/locales/en.json (+1 -0)
📝 packages/hoppscotch-common/src/components/lenses/renderers/AudioLensRenderer.vue (+45 -3)
📝 packages/hoppscotch-common/src/components/lenses/renderers/HTMLLensRenderer.vue (+43 -6)
📝 packages/hoppscotch-common/src/components/lenses/renderers/ImageLensRenderer.vue (+43 -2)
📝 packages/hoppscotch-common/src/components/lenses/renderers/JSONLensRenderer.vue (+14 -1)
📝 packages/hoppscotch-common/src/components/lenses/renderers/PDFLensRenderer.vue (+44 -3)
📝 packages/hoppscotch-common/src/components/lenses/renderers/RawLensRenderer.vue (+37 -4)
📝 packages/hoppscotch-common/src/components/lenses/renderers/VideoLensRenderer.vue (+45 -3)
📝 packages/hoppscotch-common/src/components/lenses/renderers/XMLLensRenderer.vue (+45 -5)
📝 packages/hoppscotch-common/src/helpers/actions.ts (+1 -0)
📝 packages/hoppscotch-common/src/helpers/keybindings.ts (+8 -1)

📄 Description

Closes #5431

This PR adds the ability to clear/erase API responses in the HTML lens renderer with both button click and keyboard shortcut support. Users can now quickly clear response data when needed without having to make a new request.

What's changed

  • Added erase button to HTML lens renderer toolbar with eraser icon
  • Implemented eraseResponse() function that emits update:response with null to clear response
  • Added keyboard shortcut support for Ctrl+Delete (Cmd+Delete on Mac)
  • Extended keyboard shortcut system to support "delete" key
  • Updated Key type definition to include "delete" key
  • Enhanced getPressedKey() function to handle delete key detection
  • Added global keybinding mapping for "ctrl-delete" -> "response.erase" action
  • Added action handler registration for "response.erase" action
  • Updated emit signature to support null values for response clearing
  • Added tooltip with proper keyboard shortcut display using getSpecialKey()

Notes to reviewers

  • The implementation follows the existing v-model pattern used by other lens renderers
  • The erase button only appears when there's a response body to clear (v-if="response.body")
  • The keyboard shortcut system was extended to support the delete key, which wasn't previously available
  • All TypeScript checks pass and the feature integrates seamlessly with the existing codebase
  • The feature is consistent with other response actions (copy, download, save) in terms of UI placement and behavior
  • Uses existing translation key action.clear for consistency with the rest of the application

Before Changes

No option to clear the response Body

Image

After Changes

Recording2025-10-03180746-ezgif com-video-to-gif-converter


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/hoppscotch/hoppscotch/pull/5435 **Author:** [@12fahed](https://github.com/12fahed) **Created:** 10/3/2025 **Status:** ✅ Merged **Merged:** 11/26/2025 **Merged by:** [@jamesgeorge007](https://github.com/jamesgeorge007) **Base:** `next` ← **Head:** `feat/clear-response` --- ### 📝 Commits (10+) - [`842a139`](https://github.com/hoppscotch/hoppscotch/commit/842a1392aa3aaa0c182344009b93953d3acc4b28) feat: clear response button for html & json renderer - [`6cd3980`](https://github.com/hoppscotch/hoppscotch/commit/6cd3980dc2c626f4a0ea806ed5c9233b515530a8) chore: disable clear response for examples - [`3ad9021`](https://github.com/hoppscotch/hoppscotch/commit/3ad9021d412ab98c4f5a681c4de791ee301ca064) refactor: relocate clear response (erase) action button to more menu for JSON Renderer - [`fd527b1`](https://github.com/hoppscotch/hoppscotch/commit/fd527b19e2196f25dd9bb9ec152755eab472b66e) feat: add "clear response" option in "more option" inside tippy menu for RAW renderer - [`bee549f`](https://github.com/hoppscotch/hoppscotch/commit/bee549fc352782ab444c6cdf279a4477f9be2b09) refactor: move "clear response" button to tippy more option for HTML renderer - [`cdfb4d6`](https://github.com/hoppscotch/hoppscotch/commit/cdfb4d68e4cd2f5be36a419b15653b969e8a6ac7) feat: add "clear response" option in "more option" inside tippy menu for XML renderer - [`43687f4`](https://github.com/hoppscotch/hoppscotch/commit/43687f4c9f0ba6c423d1c4ec7bf22ca8a9093443) chore: add clear response for image lense - [`07a2e00`](https://github.com/hoppscotch/hoppscotch/commit/07a2e0056143622720d25d6d44acec9cf78d75dd) chore: disable clear response for saved example - [`2806233`](https://github.com/hoppscotch/hoppscotch/commit/28062338941830ff92924f63cff194a7fcab9c13) chore: add clear response for Audio lense - [`6bbad10`](https://github.com/hoppscotch/hoppscotch/commit/6bbad103fe7116c9f83e0a011339ab741a58d4e7) chore: add clear response for PDF lense ### 📊 Changes **11 files changed** (+326 additions, -28 deletions) <details> <summary>View changed files</summary> 📝 `packages/hoppscotch-common/locales/en.json` (+1 -0) 📝 `packages/hoppscotch-common/src/components/lenses/renderers/AudioLensRenderer.vue` (+45 -3) 📝 `packages/hoppscotch-common/src/components/lenses/renderers/HTMLLensRenderer.vue` (+43 -6) 📝 `packages/hoppscotch-common/src/components/lenses/renderers/ImageLensRenderer.vue` (+43 -2) 📝 `packages/hoppscotch-common/src/components/lenses/renderers/JSONLensRenderer.vue` (+14 -1) 📝 `packages/hoppscotch-common/src/components/lenses/renderers/PDFLensRenderer.vue` (+44 -3) 📝 `packages/hoppscotch-common/src/components/lenses/renderers/RawLensRenderer.vue` (+37 -4) 📝 `packages/hoppscotch-common/src/components/lenses/renderers/VideoLensRenderer.vue` (+45 -3) 📝 `packages/hoppscotch-common/src/components/lenses/renderers/XMLLensRenderer.vue` (+45 -5) 📝 `packages/hoppscotch-common/src/helpers/actions.ts` (+1 -0) 📝 `packages/hoppscotch-common/src/helpers/keybindings.ts` (+8 -1) </details> ### 📄 Description <!-- Thanks for creating this pull request 🤗 Please make sure that the pull request is limited to one type (docs, feature, etc.) and keep it as small as possible. You can open multiple prs instead of opening a huge one. --> <!-- If this pull request closes an issue, please mention the issue number below --> Closes #5431 <!-- Add an introduction into what this PR tries to solve in a couple of sentences --> This PR adds the ability to clear/erase API responses in the HTML lens renderer with both button click and keyboard shortcut support. Users can now quickly clear response data when needed without having to make a new request. ### What's changed <!-- Describe point by point the different things you have changed in this PR --> - [x] Added erase button to HTML lens renderer toolbar with eraser icon - [x] Implemented `eraseResponse()` function that emits `update:response` with null to clear response - [x] Added keyboard shortcut support for Ctrl+Delete (Cmd+Delete on Mac) - [x] Extended keyboard shortcut system to support "delete" key - [x] Updated `Key` type definition to include "delete" key - [x] Enhanced `getPressedKey()` function to handle delete key detection - [x] Added global keybinding mapping for "ctrl-delete" -> "response.erase" action - [x] Added action handler registration for "response.erase" action - [x] Updated emit signature to support null values for response clearing - [x] Added tooltip with proper keyboard shortcut display using `getSpecialKey()` ### Notes to reviewers <!-- Any information you feel the reviewer should know about when reviewing your PR --> - The implementation follows the existing v-model pattern used by other lens renderers - The erase button only appears when there's a response body to clear (`v-if="response.body"`) - The keyboard shortcut system was extended to support the delete key, which wasn't previously available - All TypeScript checks pass and the feature integrates seamlessly with the existing codebase - The feature is consistent with other response actions (copy, download, save) in terms of UI placement and behavior - Uses existing translation key `action.clear` for consistency with the rest of the application ### Before Changes No option to clear the response Body <img width="1370" height="200" alt="Image" src="https://github.com/user-attachments/assets/dfe6db12-a1d3-4762-9db1-78e1c1b35e55" /> ### After Changes ![Recording2025-10-03180746-ezgif com-video-to-gif-converter](https://github.com/user-attachments/assets/b5d2af81-e3ab-4d67-b1be-7af73f804d13) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-03-17 02:40:23 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/hoppscotch#5204
No description provided.