bug: Input doesn't reset the cursor position after getting emptied by setValue #35

Closed
opened 2022-10-20 23:02:36 +08:00 by luiz00martins · 2 comments
luiz00martins commented 2022-10-20 23:02:36 +08:00 (Migrated from github.com)

Describe the bug

The previous position of the Input's cursor is maintained when a setValue call is followed by a setFocus call, even when the input is empty.

Minimal Working Example

--Basalt configurated installer
local filePath = "/basalt.lua" --here you can change the file path default: basalt
if not(fs.exists(filePath))then
    shell.run("pastebin run ESs1mg7P packed true "..filePath:gsub(".lua", "")) -- this is an alternative to the wget command
end
local basalt = require(filePath:gsub(".lua", ""))

local main = basalt.createFrame("mainFrame")

local input = main:addInput('input')
	:setPosition(1, 1)
	:setSize(20, 1)
	:setValue('Some Text')

local button = main:addButton('button')
	:setPosition(1, 2)
	:setSize(20, 1)
	:setValue('Button')
	:onClickUp(function()
		-- Important part
		input:setValue('')
		input:setFocus()
	end)

basalt.autoUpdate()

https://user-images.githubusercontent.com/43142209/196984044-1d5109b7-6ca2-4bff-bf01-b1cfcb68fbf4.mp4

Steps to reproduce the behavior:

  1. Type something in the Input
  2. Clear it with input:setValue('')
  3. Focus on it with input:setFocus()

Expected behavior

The cursor would return to the rightmost side of the input.

Checklist

[x] I am running the latest version.

### Describe the bug The previous position of the `Input`'s cursor is maintained when a `setValue` call is followed by a `setFocus` call, even when the input is empty. ### Minimal Working Example ```lua --Basalt configurated installer local filePath = "/basalt.lua" --here you can change the file path default: basalt if not(fs.exists(filePath))then shell.run("pastebin run ESs1mg7P packed true "..filePath:gsub(".lua", "")) -- this is an alternative to the wget command end local basalt = require(filePath:gsub(".lua", "")) local main = basalt.createFrame("mainFrame") local input = main:addInput('input') :setPosition(1, 1) :setSize(20, 1) :setValue('Some Text') local button = main:addButton('button') :setPosition(1, 2) :setSize(20, 1) :setValue('Button') :onClickUp(function() -- Important part input:setValue('') input:setFocus() end) basalt.autoUpdate() ``` https://user-images.githubusercontent.com/43142209/196984044-1d5109b7-6ca2-4bff-bf01-b1cfcb68fbf4.mp4 ### Steps to reproduce the behavior: 1. Type something in the `Input` 2. Clear it with `input:setValue('')` 3. Focus on it with `input:setFocus()` ### Expected behavior The cursor would return to the rightmost side of the input. ### Checklist [x] I am running the latest version.
piprett commented 2022-10-20 23:09:01 +08:00 (Migrated from github.com)

Can reproduce! 👍

Can reproduce! 👍
piprett commented 2022-10-21 01:09:49 +08:00 (Migrated from github.com)

After my small amount of testing, it seems this was fixed in 3dcdcfd383.

After my small amount of testing, it seems this was fixed in 3dcdcfd3831b3c5fd659529846c267fe50c3d3d6.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: GitHub/Basalt#35
No description provided.