rebootcode / svg-edit

Automatically exported from code.google.com/p/svg-edit
MIT License
0 stars 0 forks source link

id input behaves oddly #934

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Draw anything and select it
2. Click in the id input, rename the object to 'foo' and press Enter (notice 
the input is still focused)
3. Press enter again, "invalid value given" error dialog pops up
4. Select the id input again, press Enter: "Invalid value given" error dialog 
again

What is the expected output?

- when you press Enter in the id input, it should unfocus/blur the id input
- if you press Enter in the id input and the id value hasn't changed, do not 
report an error

Original issue reported on code.google.com by codedr...@gmail.com on 25 Mar 2012 at 8:13

GoogleCodeExporter commented 8 years ago
For same id (press enter again without changing name):

The problem seems to be the validation checks if element with that id already 
exist... and of course it does, it's itself. But the validation thinks it's 
different element. So we need to check if getElem() returns the same element as 
the one we're manipulating.

The unfocus/blur is trivial to add.

I'll patch this on the weekend if there are still no takers by then. I wanna 
get rid of NeededFor=2.6...

Original comment by asyazwan on 9 Apr 2012 at 6:40

GoogleCodeExporter commented 8 years ago
I was taking a look at how to fix this particular problem and it seems to me 
that there are a couple smells here:

First the name of the function really doesn't tell me anything about what it is 
doing wrt to id

Second id is clearly a different beast than other types of attributes and 
requires more context than name an attribute to definitively assert validity. 

However, soap box aside it seems like the correct fix is to get access to the 
current selected element and check to see if it is === to the element in the 
elementContainer.

Original comment by adamben...@gmail.com on 23 May 2012 at 10:28

GoogleCodeExporter commented 8 years ago
Attached is a patch to fix the 'same element' behavior.

Original comment by adamben...@gmail.com on 24 May 2012 at 4:51

Attachments:

GoogleCodeExporter commented 8 years ago
Patch applied (with minor whitespace fix on line 14) in r2083.

Thanks!

Original comment by asyazwan on 25 May 2012 at 4:05