danielperna84 / hass-configurator

Configuration UI for Home Assistant
MIT License
306 stars 168 forks source link

Feature request: place cursor in textbox when renaming files #215

Open dagwud opened 3 years ago

dagwud commented 3 years ago

Really small and silly request, but the "Rename" menu brings up a popup to prompt for the file name, but the caret is not placed in the new file name text box. I initially raised this issue against the addon but was referredreferred here by Frenck

A small usability fix (putting the cursor in the text box to allow you to just start typing) would be nice. When doing housekeeping and renaming a bunch of files, this extra click is pesky.

Environment

HAOS 5.13 core-2021.5.5 supervisor-2021.04.3

Steps to reproduce:

Open File Editor Click the "Browse Filesystem" icon Click on the "..." next to any file name Click Rename Note the popup which asks "Please enter a new name for " - if you just start typing, nothing happens as the cursor is not placed in the input box

dagwud commented 3 years ago

Hi

Looking at the code, it seems like perhaps there’s space for a neat little global fix - it looks like all pop ups with a text input have the same minor issue (eg Create New File and Create New Folder too)

I’m not familiar enough with the setup process to be able to build locally so I haven’t raised a PR with a change, but an idea (if you want it): perhaps this could be a write-once-fixed-everywhere thing. Perhaps via JS - if the modal contains only one child and it’s an input-text, then $(input).focus(); when displaying the modal

danielperna84 commented 2 years ago

Sadly I seem to fail to implement this. I have tried adding things like dd_rename_a.addEventListener("click", function() {document.getElementById('rename_name_new').focus();}, false); to the link-element (the buttons are created programmatically). I know the code gets executed. But it does not focus the input. I assume that's happening because the focus is applied before the element is drawn on the screen, and then other stuff is happening, thereby changing the focus to something else.