Skip to content

feat: implemented dynamic show/hide clear button logic#446

Open
DeepeshKafalatiya wants to merge 1 commit into
Charushi06:mainfrom
DeepeshKafalatiya:feature/clear-text-button
Open

feat: implemented dynamic show/hide clear button logic#446
DeepeshKafalatiya wants to merge 1 commit into
Charushi06:mainfrom
DeepeshKafalatiya:feature/clear-text-button

Conversation

@DeepeshKafalatiya
Copy link
Copy Markdown

Related Issue

Closes #253

Summary

This contribution enhances the UX of the "Smart Paste" text panel by making the "Clear" button dynamic. Instead of remaining statically visible or unlinked, the button now hides automatically when the text area is empty on page load, reveals itself instantly as soon as a user types or pastes text, and smoothly resets the input state upon being clicked.

Changes Made

  • Added a conditional page-load execution block in js/app.js to ensure the clear button initiates as hidden (display: none) if the textarea contains no text.
  • Enhanced the existing clearBtn click event listener to explicitly hide the button instantly and return input .focus() to the text area upon resetting.
  • Implemented a dynamic input event listener on pasteInput to actively track value lengths, triggering clearBtn.style.display toggles between 'block' and 'none'.

Testing

  • Tested locally across browsers by checking the initial UI state (button correctly hidden on load).
  • Verified the input handler by pasting multi-line unformatted text blocks (button instantly becomes visible).
  • Confirmed the reset workflow by clicking the button (text is wiped cleanly, the storage store is reset, the button hides, and the flashing cursor focus remains inside the empty input box).

Checklist

  • Code follows project style
  • Tested locally
  • No unrelated changes included
  • Documentation updated (if applicable)

@DeepeshKafalatiya
Copy link
Copy Markdown
Author

Hi Mentors,

I have successfully implemented the dynamic show/hide logic and clear functionality for the clearBtn and pasteInput elements.

The code has been tested locally and works flawlessly. I have opened a Pull Request for review here: [https://github.com//pull/446]

Please let me know if any changes or refinements are needed. Thank you!

@DeepeshKafalatiya
Copy link
Copy Markdown
Author

Hi Mentors,

I have successfully implemented the dynamic show/hide logic and clear functionality for the clearBtn and pasteInput elements.

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.

[Enhancement]: Add a "Clear Text" button to the Smart Paste / Messy Text input area

1 participant