@eturnity/eturnity_reusable_components 9.37.10 → 9.40.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.es3.js
CHANGED
|
@@ -468,7 +468,7 @@ const theme = (() => {
|
|
|
468
468
|
main: {
|
|
469
469
|
// variant: this is the default variant
|
|
470
470
|
default: {
|
|
471
|
-
backgroundColor:
|
|
471
|
+
backgroundColor: colors.white,
|
|
472
472
|
textColor: semanticColors.purple[500],
|
|
473
473
|
borderColor: "",
|
|
474
474
|
iconBackgroundColor: semanticColors.buttonIcon.none
|
package/package.json
CHANGED
package/src/assets/theme.js
CHANGED
|
@@ -469,7 +469,7 @@ const theme = (() => {
|
|
|
469
469
|
main: {
|
|
470
470
|
// variant: this is the default variant
|
|
471
471
|
default: {
|
|
472
|
-
backgroundColor:
|
|
472
|
+
backgroundColor: colors.white,
|
|
473
473
|
textColor: semanticColors.purple[500],
|
|
474
474
|
borderColor: '',
|
|
475
475
|
iconBackgroundColor: semanticColors.buttonIcon.none,
|
|
@@ -587,9 +587,7 @@
|
|
|
587
587
|
)
|
|
588
588
|
this.$emit('dropdown-search', '')
|
|
589
589
|
this.$nextTick(() => {
|
|
590
|
-
this
|
|
591
|
-
})
|
|
592
|
-
this.$nextTick(() => {
|
|
590
|
+
this.focusSearchInput()
|
|
593
591
|
this.scrollToItem()
|
|
594
592
|
})
|
|
595
593
|
}
|
|
@@ -632,13 +630,7 @@
|
|
|
632
630
|
CLICK_OUTSIDE_CAPTURE
|
|
633
631
|
)
|
|
634
632
|
this.$emit('dropdown-search', '')
|
|
635
|
-
this.$nextTick(() => {
|
|
636
|
-
this.scrollToItem()
|
|
637
|
-
})
|
|
638
633
|
this.$emit('toggle-dropdown-open', { close: false })
|
|
639
|
-
this.$nextTick(() => {
|
|
640
|
-
this.$refs.searchInput.$el.children[0].children[1].focus()
|
|
641
|
-
})
|
|
642
634
|
} else {
|
|
643
635
|
document.removeEventListener(
|
|
644
636
|
'click',
|
|
@@ -654,6 +646,10 @@
|
|
|
654
646
|
this.toggleOpen()
|
|
655
647
|
}
|
|
656
648
|
},
|
|
649
|
+
focusSearchInput() {
|
|
650
|
+
const input = this.$refs.searchInput?.$el.querySelector('input')
|
|
651
|
+
input?.focus({ preventScroll: true })
|
|
652
|
+
},
|
|
657
653
|
scrollToItem() {
|
|
658
654
|
if (this.$refs.optionsContainer) {
|
|
659
655
|
this.$refs.optionsContainer.$el.scrollIntoView({
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/* eslint-disable */
|
|
2
2
|
import { mount } from '@vue/test-utils'
|
|
3
|
+
import { h, nextTick, ref } from 'vue'
|
|
3
4
|
import TableDropdown from './index.vue'
|
|
4
5
|
import SearchInput from '@/components/inputs/searchInput'
|
|
5
6
|
import InputText from '@/components/inputs/inputText'
|
|
@@ -58,7 +59,9 @@ describe('TableDropdown', () => {
|
|
|
58
59
|
|
|
59
60
|
it('renders a template link with the value for a filled template item', () => {
|
|
60
61
|
const wrapper = mountDropdown({
|
|
61
|
-
tableItems: [
|
|
62
|
+
tableItems: [
|
|
63
|
+
{ type: 'template', value: 'My Template', row: { id: 2 } },
|
|
64
|
+
],
|
|
62
65
|
})
|
|
63
66
|
expect(wrapper.text()).toContain('My Template')
|
|
64
67
|
expect(wrapper.findComponent(MainButton).exists()).toBe(false)
|
|
@@ -130,6 +133,74 @@ describe('TableDropdown', () => {
|
|
|
130
133
|
})
|
|
131
134
|
})
|
|
132
135
|
|
|
136
|
+
describe('opening: focus and scroll', () => {
|
|
137
|
+
let scrollIntoView
|
|
138
|
+
let focus
|
|
139
|
+
|
|
140
|
+
// The dropdown lives in a parent that owns `isOpen`, so one click runs both
|
|
141
|
+
// toggleOpen and the isOpen watcher, exactly as it does in the app.
|
|
142
|
+
const mountControlled = (props = {}) => {
|
|
143
|
+
const isOpen = ref(false)
|
|
144
|
+
return mount({
|
|
145
|
+
setup() {
|
|
146
|
+
return () =>
|
|
147
|
+
h(TableDropdown, {
|
|
148
|
+
colSpan: 2,
|
|
149
|
+
tableItems: [{ type: 'text', value: 'Selected Item' }],
|
|
150
|
+
optionItems: [
|
|
151
|
+
{ display_name: 'Item 1', company_item_number: '123' },
|
|
152
|
+
{ display_name: 'Item 2', company_item_number: '456' },
|
|
153
|
+
],
|
|
154
|
+
optionsDisplay: ['display_name', 'company_item_number'],
|
|
155
|
+
...props,
|
|
156
|
+
isOpen: isOpen.value,
|
|
157
|
+
onToggleDropdownOpen: ({ close }) => {
|
|
158
|
+
isOpen.value = !close
|
|
159
|
+
},
|
|
160
|
+
})
|
|
161
|
+
},
|
|
162
|
+
})
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
const open = async (wrapper) => {
|
|
166
|
+
await wrapper.findComponent(TableDropdown).trigger('click')
|
|
167
|
+
await nextTick()
|
|
168
|
+
await nextTick()
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
beforeEach(() => {
|
|
172
|
+
scrollIntoView = jest.fn()
|
|
173
|
+
Element.prototype.scrollIntoView = scrollIntoView
|
|
174
|
+
focus = jest.spyOn(HTMLInputElement.prototype, 'focus')
|
|
175
|
+
})
|
|
176
|
+
|
|
177
|
+
afterEach(() => {
|
|
178
|
+
focus.mockRestore()
|
|
179
|
+
})
|
|
180
|
+
|
|
181
|
+
it('focuses the search input without letting focus scroll the page', async () => {
|
|
182
|
+
const wrapper = mountControlled()
|
|
183
|
+
await open(wrapper)
|
|
184
|
+
|
|
185
|
+
expect(focus).toHaveBeenCalledTimes(1)
|
|
186
|
+
expect(focus).toHaveBeenCalledWith({ preventScroll: true })
|
|
187
|
+
expect(focus.mock.instances[0]).toBe(
|
|
188
|
+
wrapper.findComponent(SearchInput).find('input').element
|
|
189
|
+
)
|
|
190
|
+
})
|
|
191
|
+
|
|
192
|
+
it('scrolls the options container into view once, smoothly', async () => {
|
|
193
|
+
const wrapper = mountControlled()
|
|
194
|
+
await open(wrapper)
|
|
195
|
+
|
|
196
|
+
expect(scrollIntoView).toHaveBeenCalledTimes(1)
|
|
197
|
+
expect(scrollIntoView).toHaveBeenCalledWith({
|
|
198
|
+
behavior: 'smooth',
|
|
199
|
+
block: 'center',
|
|
200
|
+
})
|
|
201
|
+
})
|
|
202
|
+
})
|
|
203
|
+
|
|
133
204
|
describe('interactions', () => {
|
|
134
205
|
it('emits toggle-dropdown-open with close:true when an open row is clicked', async () => {
|
|
135
206
|
const wrapper = mountDropdown({ isOpen: true })
|