mirror of
https://github.com/MoonshotAI/kimi-code.git
synced 2026-08-12 18:27:39 +00:00
fix(apps/kimi-code): allow deselecting Other option in multi-select question dialog (#2810)
This commit is contained in:
parent
860354976e
commit
64abebc95a
3 changed files with 47 additions and 0 deletions
5
.changeset/fix-multi-select-other-deselect.md
Normal file
5
.changeset/fix-multi-select-other-deselect.md
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
"@moonshot-ai/kimi-code": patch
|
||||
---
|
||||
|
||||
Fix multi-select "Other" options so they can be deselected after being committed.
|
||||
|
|
@ -299,6 +299,12 @@ export class QuestionDialogComponent extends Container implements Focusable {
|
|||
this.reviewMessage = undefined;
|
||||
|
||||
if (this.isOtherOption(questionIdx, optionIdx)) {
|
||||
if (question.multi_select && this.multiSelections[questionIdx]?.has(optionIdx)) {
|
||||
this.multiSelections[questionIdx].delete(optionIdx);
|
||||
this.lastAnswerMethod = method;
|
||||
this.updateAnswer(questionIdx);
|
||||
return;
|
||||
}
|
||||
this.enterOtherInput(questionIdx);
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -394,6 +394,42 @@ describe('QuestionDialogComponent', () => {
|
|||
expect(out).toContain('Mushroom');
|
||||
});
|
||||
|
||||
it('multi-select Other can be toggled off after it is committed', () => {
|
||||
const pending = makePending([
|
||||
{
|
||||
question: 'Pick toppings?',
|
||||
multi_select: true,
|
||||
options: [{ label: 'Cheese' }, { label: 'Pepperoni' }],
|
||||
},
|
||||
]);
|
||||
const { dialog, collected } = makeDialog(pending);
|
||||
|
||||
// Select Other and commit a custom value.
|
||||
dialog.handleInput('3');
|
||||
dialog.handleInput('M');
|
||||
dialog.handleInput('u');
|
||||
dialog.handleInput('s');
|
||||
dialog.handleInput('h');
|
||||
dialog.handleInput('r');
|
||||
dialog.handleInput('o');
|
||||
dialog.handleInput('o');
|
||||
dialog.handleInput('m');
|
||||
dialog.handleInput('\r');
|
||||
|
||||
// Toggle it off using the same key.
|
||||
dialog.handleInput('3');
|
||||
// Select a preset option to confirm the answer still builds correctly.
|
||||
dialog.handleInput('1');
|
||||
dialog.handleInput('\t');
|
||||
|
||||
const review = strip(dialog.render(80).join('\n'));
|
||||
expect(review).toContain('Cheese');
|
||||
expect(review).not.toContain('Mushroom');
|
||||
|
||||
dialog.handleInput('1');
|
||||
expect(collected).toEqual([['Cheese']]);
|
||||
});
|
||||
|
||||
it('escape dismisses with empty answers array', () => {
|
||||
const pending = makePending([
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue