diff --git a/superset-frontend/src/SqlLab/components/QueryLimitSelect/QueryLimitSelect.test.tsx b/superset-frontend/src/SqlLab/components/QueryLimitSelect/QueryLimitSelect.test.tsx index 8d421f92c92e..3b992a6dd752 100644 --- a/superset-frontend/src/SqlLab/components/QueryLimitSelect/QueryLimitSelect.test.tsx +++ b/superset-frontend/src/SqlLab/components/QueryLimitSelect/QueryLimitSelect.test.tsx @@ -123,7 +123,9 @@ describe('QueryLimitSelect', () => { elem.textContent?.trim(), ); - expect(actualLabels).toEqual(expectedLabels); + expect(actualLabels.slice(0, actualLabels.length - 1)).toEqual( + expectedLabels, + ); }); it('renders dropdown select correctly when maxRow is less than 10', async () => { @@ -143,7 +145,9 @@ describe('QueryLimitSelect', () => { elem.textContent?.trim(), ); - expect(actualLabels).toEqual(expectedLabels); + expect(actualLabels.slice(0, actualLabels.length - 1)).toEqual( + expectedLabels, + ); }); it('renders dropdown select correctly when maxRow is a multiple of 10', async () => { @@ -165,7 +169,9 @@ describe('QueryLimitSelect', () => { elem.textContent?.trim(), ); - expect(actualLabels).toEqual(expectedLabels); + expect(actualLabels.slice(0, actualLabels.length - 1)).toEqual( + expectedLabels, + ); }); it('dispatches QUERY_EDITOR_SET_QUERY_LIMIT action on dropdown menu click', async () => { diff --git a/superset-frontend/src/SqlLab/components/QueryLimitSelect/index.tsx b/superset-frontend/src/SqlLab/components/QueryLimitSelect/index.tsx index 9e2e89aad03c..bdc837eee091 100644 --- a/superset-frontend/src/SqlLab/components/QueryLimitSelect/index.tsx +++ b/superset-frontend/src/SqlLab/components/QueryLimitSelect/index.tsx @@ -20,6 +20,7 @@ import { useDispatch } from 'react-redux'; import { t } from '@superset-ui/core'; import { Dropdown } from 'src/components/Dropdown'; import { Menu } from 'src/components/Menu'; +import { Input } from 'src/components/Input'; import { Icons } from 'src/components/Icons'; import { queryEditorSetQueryLimit } from 'src/SqlLab/actions/sqlLab'; import useQueryEditor from 'src/SqlLab/hooks/useQueryEditor'; @@ -55,6 +56,23 @@ function renderQueryLimit( {convertToNumWithSpaces(limit)}{' '} ))} + + e.stopPropagation()} + onKeyDown={event => { + if (event.key === 'Enter') { + const val = (event.target as HTMLInputElement).value; + let limit = parseInt(val, 10); + if (limit < 1) limit = 1; + setQueryLimit(limit); + convertToNumWithSpaces(limit); + } + }} + /> + ); }