Skip to content
Merged
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
49 changes: 49 additions & 0 deletions shell/components/__tests__/NamespaceFilter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -244,4 +244,53 @@ describe('component: NamespaceFilter', () => {

it.todo('should generate the options based on the Rancher resources');
});

describe('given filter input text selection', () => {
it('should allow text selection by stopping mousedown propagation', async() => {
const wrapper = mount(NamespaceFilter, {
computed: {
filtered: () => [],
options: () => [],
value: () => [],
},
global: {
mocks: {
t: (key: string) => key,
$store: { getters: { 'i18n/t': () => '', namespaceFilterMode: () => undefined } },
$fetchState: { pending: false }
},
directives: {
'clean-tooltip': () => {},
shortkey: () => {},
},
stubs: { RcButton: { template: '<button><slot /></button>' } },
}
});

// Open the dropdown to reveal the filter input
const dropdown = wrapper.find('[data-testid="namespaces-dropdown"]');

await dropdown.trigger('click');

// Find the filter input
const filterInput = wrapper.find('.ns-filter-input');

expect(filterInput.exists()).toBe(true);

// Trigger mousedown on the filter input and capture the event
const mousedownEvent = new MouseEvent('mousedown', {
bubbles: true,
cancelable: true
});
const stopPropagationSpy = jest.spyOn(mousedownEvent, 'stopPropagation');

filterInput.element.dispatchEvent(mousedownEvent);

// Verify stopPropagation was called (which allows text selection)
expect(stopPropagationSpy).toHaveBeenCalledWith();

// Verify the default was NOT prevented (text selection should work)
expect(mousedownEvent.defaultPrevented).toBe(false);
});
});
});
1 change: 1 addition & 0 deletions shell/components/nav/NamespaceFilter.vue
Original file line number Diff line number Diff line change
Expand Up @@ -841,6 +841,7 @@ export default {
tabindex="0"
class="ns-filter-input"
:aria-label="t('namespaceFilter.input')"
@mousedown.stop
@click="focusFilter"
@keydown="inputKeyHandler($event)"
>
Expand Down
Loading