If a text field is used in a fetch context and as a refetch-trigger of a dynamically populated dropdown field, the data that is sent to the ajax callback is out of sync (doesn't contain the latest entered value, depending on how fast the user types).
I assume that there is some kind of debouncing issue that comes from the fact that I want to use a text field (changes are applied on keydown in rapid succession) and not a dropdown field as the refetch-trigger?
Steps to reproduce
Create new element in Element Studio (or open up an existing one)
Add a Dropdown field to the element
Register an ajax handler (via \Breakdance\AJAX\register_handler, sample code below btw) which is used to populate the created dropdown field
Add a text field (I assume all fields which trigger a value change on keydown have this issue)
Configure the dropdown field:
Populate from server data: Use the previously created ajax callback (Step 3)
Fetch context path: Use a path which includes the previously created text field (Step 4)
Refetch data if control's value changes: The previously created text field (Step 4)
Enter a value in the text field, this causes a refetch of the dropdown data. But the returned data is out of sync. Depending on how fast you type, the value that is submitted to the server as fetch context doesn't contain all entered characters!
Additional info
Dropdown options:
Ajax handler (returns the received context as value for debugging purposes):
Summary
If a text field is used in a fetch context and as a refetch-trigger of a dynamically populated dropdown field, the data that is sent to the ajax callback is out of sync (doesn't contain the latest entered value, depending on how fast the user types).
I assume that there is some kind of debouncing issue that comes from the fact that I want to use a text field (changes are applied on keydown in rapid succession) and not a dropdown field as the refetch-trigger?
Steps to reproduce
\Breakdance\AJAX\register_handler
, sample code below btw) which is used to populate the created dropdown fieldAdditional info
Dropdown options:![2023-11-26_19 10 03_screenshot@2x](https://github.com/soflyy/breakdance-bugs/assets/106167527/c6bb5ec2-2f0a-4da7-90b3-d26678ab382d)
Ajax handler (returns the received context as value for debugging purposes):
Versions: Breakdance Version: 1.6.1 WP Version: 6.4.1 Browser: Chrome 119 OS: Mac OS Ventura