Repository navigation
Fix ctx.triggered and args_grouping for pattern-matching ids with non-ASCII characters - #4241
Open
farisbasha wants to merge 2 commits into
Open
farisbasha wants to merge 2 commits into
farisbasha wants to merge 2 commits into
Conversation
The renderer's stringifyId uses JSON.stringify, which leaves non-ASCII
characters as they are, while stringify_id escaped them as \uXXXX. The
changedPropIds sent by the renderer are looked up in strings made by
stringify_id, so with a pattern-matching id such as {"index": "café"}
ctx.triggered gave value None and args_grouping marked nothing as
triggered.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



stringify_idescapes non-ASCII characters (json.dumpsdefault), but the renderer'sstringifyIdusesJSON.stringify, which keeps them as they are. The renderer buildschangedPropIdswith its version, and the backend looks those strings up in keys made bystringify_id, so they never match when a dict id value (or key) has a non-ASCII character.Repro (posting what the renderer sends for a click on the first button):
ctx.triggered[0]["value"]isNoneinstead of the clicked button'sn_clicks, no entry inctx.args_groupingis marked as triggered, andctx.inputsis keyed by the escaped form. With ASCII ids all of this works.Fix:
stringify_idpassesensure_ascii=Falsefor the key and value, so it gives the same string as the renderer. Other escapes (quotes, control characters) are the same in both.Contributor Checklist
dev(fix or chore) ornext(feature, new API, breaking change), see Which branch to targetstringify_idmatch the renderer'sstringifyIdfor non-ASCII charactersstringify_idand forctx.triggered/ctx.args_groupingthrough/_dash-update-componentoptionals
CHANGELOG.mdTests run
On a Linux server (Python 3.12): the two new tests fail on
devand pass with the change.pytest tests/unit: 771 passed, 7 skipped, 5 failed; the same 5 fail without the change in this setup (generated component files copied from the 4.5.2 wheel: 4test_dash_table_typingcases, andtest_process_server_smoke, which needstests/assets, not checked out).black22.3.0 andflake8are clean on the changed files,pylintondash/_utils.py. Integration (Selenium) tests were not run.This PR was prepared with AI assistance (Claude).