Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,14 @@ async function applyStarterPack(boardId: string, starterPackId: string): Promise
}
}

function onBoardNameKeydown(event: KeyboardEvent) {
if (event.isComposing) {
return
}

void submitSetup()
}

async function submitSetup() {
if (!canSubmit.value || !selectedSetup.value) {
return
Expand Down Expand Up @@ -154,7 +162,7 @@ watch(
type="text"
maxlength="100"
placeholder="For example: Product Sprint"
@keydown.enter.prevent="submitSetup"
@keydown.enter.prevent="onBoardNameKeydown"
/>
</label>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,38 @@ describe('WorkspaceSetupModal', () => {
expect(mocks.push).toHaveBeenCalledWith('/workspace/boards/board-1')
})

it('ignores Enter while IME composition is active, then submits ordinary Enter once', async () => {
const wrapper = mount(WorkspaceSetupModal, {
props: {
isOpen: true,
},
})

const input = wrapper.get('input[placeholder="For example: Product Sprint"]')
await input.setValue('IME Board')

const composingEnter = new KeyboardEvent('keydown', {
key: 'Enter',
isComposing: true,
bubbles: true,
cancelable: true,
})
expect(input.element.dispatchEvent(composingEnter)).toBe(false)
await waitForUi()
expect(mocks.createBoard).not.toHaveBeenCalled()

const ordinaryEnter = new KeyboardEvent('keydown', {
key: 'Enter',
bubbles: true,
cancelable: true,
})
expect(input.element.dispatchEvent(ordinaryEnter)).toBe(false)
await waitForUi()

expect(mocks.createBoard).toHaveBeenCalledTimes(1)
expect(mocks.createBoard).toHaveBeenCalledWith({ name: 'IME Board' })
})

it('cancels on a dispatched Escape while allowing the submitting lock to hold', async () => {
const wrapper = mount(WorkspaceSetupModal, {
props: {
Expand Down
Loading