haya-select 1.0.21 → 1.0.23
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/package.json +1 -1
- package/src/select/index.jsx +21 -10
package/package.json
CHANGED
package/src/select/index.jsx
CHANGED
|
@@ -141,7 +141,7 @@ export default class HayaSelect extends React.PureComponent {
|
|
|
141
141
|
}
|
|
142
142
|
|
|
143
143
|
render() {
|
|
144
|
-
const {currentSelectedRef, endOfSelectRef} = this.t
|
|
144
|
+
const {currentSelectedRef, endOfSelectRef, onSelectClicked, onSearchTextInputChangedDebounced} = this.t
|
|
145
145
|
const {
|
|
146
146
|
attribute,
|
|
147
147
|
className,
|
|
@@ -178,13 +178,13 @@ export default class HayaSelect extends React.PureComponent {
|
|
|
178
178
|
className="haya-select-current-selected"
|
|
179
179
|
data-opened={opened}
|
|
180
180
|
data-options-placement={optionsPlacement}
|
|
181
|
-
onClick={
|
|
181
|
+
onClick={onSelectClicked}
|
|
182
182
|
ref={currentSelectedRef}
|
|
183
183
|
>
|
|
184
184
|
{opened &&
|
|
185
185
|
<input
|
|
186
186
|
className="haya-select-search-text-input"
|
|
187
|
-
onChange={
|
|
187
|
+
onChange={onSearchTextInputChangedDebounced}
|
|
188
188
|
placeholder={I18n.t("haya_select.search_dot_dot_dot")} type="text"
|
|
189
189
|
ref={this.t.searchTextInputRef}
|
|
190
190
|
/>
|
|
@@ -240,6 +240,14 @@ export default class HayaSelect extends React.PureComponent {
|
|
|
240
240
|
}
|
|
241
241
|
}
|
|
242
242
|
|
|
243
|
+
isActive() {
|
|
244
|
+
if (this.t.endOfSelectRef.current) {
|
|
245
|
+
return true
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
return false
|
|
249
|
+
}
|
|
250
|
+
|
|
243
251
|
async loadDefaultValuesFromOptionsCallback() {
|
|
244
252
|
const defaultValues = this.defaultValues()
|
|
245
253
|
|
|
@@ -329,6 +337,8 @@ export default class HayaSelect extends React.PureComponent {
|
|
|
329
337
|
focusTextInput = () => digg(this.t.searchTextInputRef, "current").focus()
|
|
330
338
|
|
|
331
339
|
setOptionsPosition() {
|
|
340
|
+
if (!this.isActive()) return // Debounce after un-mount handeling.
|
|
341
|
+
|
|
332
342
|
this.setOptionsPositionBelow()
|
|
333
343
|
this.setOptionsPositionAboveIfOutsideScreen()
|
|
334
344
|
}
|
|
@@ -348,7 +358,7 @@ export default class HayaSelect extends React.PureComponent {
|
|
|
348
358
|
}
|
|
349
359
|
|
|
350
360
|
setOptionsPositionAbove() {
|
|
351
|
-
const {optionsContainerRef, currentSelectedRef} = this.t
|
|
361
|
+
const {optionsContainerRef, currentSelectedRef, searchTextInputRef} = this.t
|
|
352
362
|
const optionsHeight = digg(optionsContainerRef, "current", "offsetHeight")
|
|
353
363
|
const position = currentSelectedRef.current.getBoundingClientRect()
|
|
354
364
|
const {left, top, width} = digs(position, "left", "top", "width")
|
|
@@ -365,12 +375,12 @@ export default class HayaSelect extends React.PureComponent {
|
|
|
365
375
|
scrollLeft: document.documentElement.scrollLeft,
|
|
366
376
|
scrollTop: document.documentElement.scrollTop
|
|
367
377
|
},
|
|
368
|
-
() =>
|
|
378
|
+
() => searchTextInputRef.current.focus()
|
|
369
379
|
)
|
|
370
380
|
}
|
|
371
381
|
|
|
372
382
|
setOptionsPositionBelow() {
|
|
373
|
-
const {endOfSelectRef} = this.t
|
|
383
|
+
const {endOfSelectRef, searchTextInputRef} = this.t
|
|
374
384
|
const position = endOfSelectRef.current.getBoundingClientRect()
|
|
375
385
|
const {left, top, width} = digs(position, "left", "top", "width")
|
|
376
386
|
|
|
@@ -385,7 +395,7 @@ export default class HayaSelect extends React.PureComponent {
|
|
|
385
395
|
scrollLeft: document.documentElement.scrollLeft,
|
|
386
396
|
scrollTop: document.documentElement.scrollTop
|
|
387
397
|
},
|
|
388
|
-
() =>
|
|
398
|
+
() => searchTextInputRef.current.focus()
|
|
389
399
|
)
|
|
390
400
|
}
|
|
391
401
|
|
|
@@ -447,9 +457,9 @@ export default class HayaSelect extends React.PureComponent {
|
|
|
447
457
|
)
|
|
448
458
|
}
|
|
449
459
|
|
|
450
|
-
onOptionClicked = (
|
|
451
|
-
|
|
452
|
-
|
|
460
|
+
onOptionClicked = (event, loadedOption) => {
|
|
461
|
+
event.preventDefault()
|
|
462
|
+
event.stopPropagation()
|
|
453
463
|
|
|
454
464
|
const {onChange, toggleOptions} = this.props
|
|
455
465
|
const {multiple} = this.p
|
|
@@ -500,6 +510,7 @@ export default class HayaSelect extends React.PureComponent {
|
|
|
500
510
|
}
|
|
501
511
|
|
|
502
512
|
onChange({
|
|
513
|
+
event,
|
|
503
514
|
options: this.shape.currentOptions,
|
|
504
515
|
toggles
|
|
505
516
|
})
|