ScratchAddons icon indicating copy to clipboard operation
ScratchAddons copied to clipboard

Search sprites and sprites folder to not cooperate properly.

Open WindsorYeh-School opened this issue 2 years ago • 15 comments

Description

With the "search sprite" feature, I cannot search for sprites that are contained inside an unopened folder. Opened folders work as expected.

Steps to reproduce

1.Install the extension. 2.Enable both "Sprite folders" by GarboMuffin and "Search box in sprite pane" by BarelySmooth and GarboMuffin. 3.In a project, add some sprites into a folder and close the folder. 4.Search for the contained sprites. Those sprites in the closed folder do not show up in the results.

Demonstration(s) and additional context

Unable to provide screenshots for now.

Environment

Google Chrome | 120.0.6099.200 (Official Build) (64-bit) (cohort: Stable Installs & Version Pins) -- | -- Revision | 4c400b5eade71f580ad9e320a2c4634dc5a0a0f9-refs/branch-heads/6099@{#1669} OS | Windows 10 Version 22H2 (Build 19045.3803) JavaScript | V8 12.0.267.14

WindsorYeh-School avatar Mar 25 '24 09:03 WindsorYeh-School

It is working as it is supposed to be, to search in a folder you're supposed to open it. Think about how folders and files work on your computer.

Waakul avatar Mar 25 '24 11:03 Waakul

It is working as it is supposed to be, to search in a folder you're supposed to open it. Think about how folders and files work on your computer.

At least on Windows, searching in a folder includes all subfolders. I think users will expect a similar behavior here.

mxmou avatar Mar 25 '24 13:03 mxmou

It is working as it is supposed to be, to search in a folder you're supposed to open it. Think about how folders and files work on your computer.

At least on Windows, searching in a folder includes all subfolders. I think users will expect a similar behavior here.

Yes, indeed we can search for subfolders in a folder... And we can search folders here?

Waakul avatar Mar 25 '24 13:03 Waakul

The issue here seems to be that folders are treated just like sprites. When the folder is closed, the sprites in that folder are not considered to exist.

Sprites called "In folder 1" and "In folder 2" in a folder called "Folder", and two sprites "Not in fold..." not in that folder. Folder closed: Two sprites called "Not in fold..." while "in fo" is being searched for Folder opened: Sprites called "In folder 1" and "In folder 2" in a folder, and two sprites "Not in fold..." not in that folder, while "in fol" is being searched for. The folder is not visible.

Here, the two sprites in the folder were renamed to "In 1" and "In 2", so the query doesn't match. Two sprites called "Not in fold..." while "fol" is being searched for. Additionally, there's an opened folder called "Folder" that doesn't have any contents.

mybearworld avatar Mar 25 '24 13:03 mybearworld

The issue here seems to be that folders are treated just like sprites. When the folder is closed, the sprites in that folder are not considered to exist.

Sprites called "In folder 1" and "In folder 2" in a folder called "Folder", and two sprites "Not in fold..." not in that folder. Folder closed: Two sprites called "Not in fold..." while "in fo" is being searched for Folder opened: Sprites called "In folder 1" and "In folder 2" in a folder, and two sprites "Not in fold..." not in that folder, while "in fol" is being searched for. The folder is not visible.

Here, the two sprites in the folder were renamed to "In 1" and "In 2", so the query doesn't match. Two sprites called "Not in fold..." while "fol" is being searched for. Additionally, there's an opened folder called "Folder" that doesn't have any contents.

It's supposed to act like that tbh. if the folder is closed, it's not supposed to display sprites inside that....

Waakul avatar Mar 25 '24 13:03 Waakul

It's supposed to act like that tbh. if the folder is closed, it's not supposed to display sprites inside that....

But then you have to, before your search, open all the folders you want to search in.

I think it should always show folders if their name or a name of a sprite inside of them matches the search query, regardless of if they're opened or closed.

mybearworld avatar Mar 25 '24 13:03 mybearworld

My expectation here is that the add-on is supposed to know the existence of the sprites inside the closed folders. I am aware that the issue is caused by the folders being treated as sprites. The reason why we should be able to search for sprites inside closed folders is because that way, we can instantly locate the sprites without having to plow through the folders we have created.

windsoryeh avatar Mar 30 '24 10:03 windsoryeh

The issue here seems to be that folders are treated just like sprites. When the folder is closed, the sprites in that folder are not considered to exist. Sprites called "In folder 1" and "In folder 2" in a folder called "Folder", and two sprites "Not in fold..." not in that folder. Folder closed: Two sprites called "Not in fold..." while "in fo" is being searched for Folder opened: Sprites called "In folder 1" and "In folder 2" in a folder, and two sprites "Not in fold..." not in that folder, while "in fol" is being searched for. The folder is not visible. Here, the two sprites in the folder were renamed to "In 1" and "In 2", so the query doesn't match. Two sprites called "Not in fold..." while "fol" is being searched for. Additionally, there's an opened folder called "Folder" that doesn't have any contents.

It's supposed to act like that tbh. if the folder is closed, it's not supposed to display sprites inside that....

If we weren't able to search for contents of closed folders, we would have to open EVERY folders in able to search for all sprites, by the time we would have already located where the sprite was. By the way, the addon could do well with an option to open or close every folders.

windsoryeh avatar Mar 30 '24 10:03 windsoryeh

What about the following fix: When the user searches for a sprite by name...

  1. Remember which folders are opened and which ones are closed
  2. Open all folders
  3. Search for the sprite When the search is cleared, close the folders that were closed before the search.

iqnite avatar Mar 31 '24 21:03 iqnite

@iqnite Sounds reasonable.

WorldLanguages avatar Apr 03 '24 18:04 WorldLanguages

That's the way to go 😀

windsoryeh avatar Apr 04 '24 02:04 windsoryeh

Is there a way to share info between addons?

iqnite avatar Apr 04 '24 09:04 iqnite

@iqnite In this case, I think ideally the folders addon should expose 2 functions: one that opens all folders, and a getter/setter for the state of which folders are open. Consider that theoretically, folders can be renamed or deleted while a search is taking place, so it needs a bit of validation.

WorldLanguages avatar Apr 04 '24 14:04 WorldLanguages

Is there a way to share info between addons?

For prototyping, it's okay to attach things to the global window object or using any other way to expose data/methods. Before actually merging it, we'd try to use standard JS modules instead.

WorldLanguages avatar Apr 04 '24 14:04 WorldLanguages

Last time I checked, folders does expose a few methods as a module. Maybe something's there that would be useful for this.

mybearworld avatar Apr 04 '24 15:04 mybearworld