Repository navigation
refactor(ui): move block callbacks inside v-bind objects in examples into named methods - #427
Merged
Merged
Conversation
…into named methods Follow-up to #424 (#141). Some CContextMenu, CMenu and CSplitButton snippets pass callbacks inside `v-bind="{ onOpenChange: (...) => { ... } }"` objects rather than as `:on*` attributes. The ten that had a block body now live in each snippet's `js` `methods` block under a name that says what they do; single-expression callbacks stay inline. The methods keep each callback's arguments, `this` reads and writes, side-effect order, and return value. The return value matters here: CContextMenu reads a literal `true` from onOpenChange as the owner claiming the opening, so every `return true`, `return false` and bare `return` stays where it was. No e2e test loaded these snippets, so eight new ones do. They pass on the old and new files, and dropping a claim's `return true` or a data write makes them fail. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…m test The browser's own menu, shown after a refused claim, selects the word under the pointer, and CContextMenu leaves a target with a selection to the browser's menu as api.md documents. The test now clears the selection and says so, in place of a left click that only happened to clear it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.
Follow-up to #424 (#141). Some CContextMenu, CMenu and CSplitButton snippets pass callbacks inside
v-bind="{ onOpenChange: (...) => { ... } }"objects rather than as:on*attributes. This PR moves the ten that had a block body into named methods in each snippet'sjsblock. Single-expression callbacks stay inline.ccontext_menu/snippets/controlled_open.pyclaimOpenRequestccontext_menu/snippets/focus_and_keyboard.pychangeReturnTargetccontext_menu/snippets/positioning_and_rtl.pyrecordAcceptedPoint,claimExternalOpenccontext_menu/snippets/touch_and_pen.pyrecordTouchRequest,refuseScrollCardRequestcmenu/snippets/controlled_open.pyapplyOpenRequestcsplitbutton/snippets/controlled_menu.pyapplyOpenRequestcsplitbutton/snippets/layers_and_dialog.pyapplyLayerActionBehaviour is unchanged. Each method keeps the callback's arguments, its
thisreads and writes, the order of its side effects, and its return value. The return value matters here: when CContextMenu'sonOpenChangereturns a literaltrue, the owner has claimed the opening. So everyreturn true,return false, and barereturnstays where it was.Proof:
test_ccontext_menu_examples_e2e.py,test_cmenu_examples_e2e.py, andtest_csplitbutton_examples_e2e.py.return true;return false.Found along the way, and explained: after a refused claim, the next right click on the same target didn't call
onOpenChangeuntil a left click. The cause is that the browser's own menu, which opens after a refused claim, selects the word under the pointer. CContextMenu then leaves a target with a selection to the browser's menu, asapi.mddocuments. Headed Chromium does the same. This is the documented behaviour, not a bug, so the test now clears the selection explicitly and says why.Single-line block-bodied handlers remain in the
ccalendar,cdate_picker, andctoursnippets. They are outside #141's multiline scope.🤖 Generated with Claude Code