My question could be solved by the comments of mickmackusa and Sharky.
I have finally extended the JFormFieldGroupedList as follows:
defined('JPATH_PLATFORM') or die;
JLoader::register('FieldsHelper', JPATH_ADMINISTRATOR . '/components/com_fields/helpers/fields.php'); //load fields helper
I duplicated your scenario (using the TinyMCE editor which is the base of JCE editor too) and it looks like for me that the toggleEditor() function is "handling" this interesting behavior within the Modal for the editor (as it is placing the editor in the document body when invoked, but that is only a half solution here). Thus, this script solved ...
Looking at the source code for com_content - ArticlesModel does not have any filtering capabilities for custom fields. What it does have is tag filtering, so would it be possible to modify your code so that instead of writing a value to a custom field you instead assign a custom tag to the article which you can then use filter.tag when getting your ...
I have reverse engineered a minimal verifiable example on db-fiddle.com based on your question and answer details.
Using my reduced and generic sample data with the sql in your answer, the output is: (DB Fiddle Demo)
There are many issues with your plugin. First, it doesn't follow the naming convention so your class doesn't get detected at all. See Creating a Plugin for Joomla tutorial for an example of correct class naming.
Assuming your component is using com_categories to manage categories, the plugin is using categories plugin group but it should be using content ...
SAVE THE DATA
I want to share how I have created the solution to my problem.
Along with the plugin there is a component than is relate with the work I doing, and both will work together. The component has other purposes, but taking advantage of the fact that much of the logic that the plugin needs, is already made or is reusable through the model classes, ...
This is what I finally did. If someone knows a cleaner solution please let me know.
defined('JPATH_BASE') or die;
class JFormFieldObjecttypes extends JFormFieldList
protected $type = 'Objecttypes';
public function getOptions(...