@etsoo/react 1.4.28 → 1.4.29
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/lib/mu/SearchBar.js +4 -5
- package/package.json +1 -1
- package/src/mu/SearchBar.tsx +5 -5
package/lib/mu/SearchBar.js
CHANGED
|
@@ -65,15 +65,13 @@ export function SearchBar(props) {
|
|
|
65
65
|
// Drawer open / close
|
|
66
66
|
const [open, updateOpen] = React.useState(false);
|
|
67
67
|
// State
|
|
68
|
-
const state = React.useRef({}).current;
|
|
68
|
+
const state = React.useRef({ hasMore: true }).current;
|
|
69
69
|
const lastMaxWidth = (_a = state.lastMaxWidth) !== null && _a !== void 0 ? _a : 9999;
|
|
70
70
|
// Watch container
|
|
71
71
|
const { dimensions } = useDimensions(1, (target, rect) => {
|
|
72
72
|
// Same logic from resetButtonRef
|
|
73
73
|
if (rect.width === lastMaxWidth ||
|
|
74
|
-
(
|
|
75
|
-
index >= fields.length &&
|
|
76
|
-
rect.width > lastMaxWidth))
|
|
74
|
+
(!state.hasMore && rect.width > lastMaxWidth))
|
|
77
75
|
return false;
|
|
78
76
|
// Len
|
|
79
77
|
const len = target.children.length;
|
|
@@ -102,7 +100,7 @@ export function SearchBar(props) {
|
|
|
102
100
|
// Container width
|
|
103
101
|
let maxWidth = containerRect.width;
|
|
104
102
|
if (maxWidth === lastMaxWidth ||
|
|
105
|
-
(
|
|
103
|
+
(!state.hasMore && maxWidth > lastMaxWidth)) {
|
|
106
104
|
return;
|
|
107
105
|
}
|
|
108
106
|
state.lastMaxWidth = maxWidth;
|
|
@@ -164,6 +162,7 @@ export function SearchBar(props) {
|
|
|
164
162
|
}
|
|
165
163
|
}
|
|
166
164
|
// Show or hide more button
|
|
165
|
+
state.hasMore = hasMore;
|
|
167
166
|
setElementVisible(buttonMore, hasMore);
|
|
168
167
|
setElementVisible(resetButton, true);
|
|
169
168
|
// Update menu start index
|
package/package.json
CHANGED
package/src/mu/SearchBar.tsx
CHANGED
|
@@ -105,7 +105,8 @@ export function SearchBar(props: SearchBarProps) {
|
|
|
105
105
|
moreForm?: HTMLFormElement;
|
|
106
106
|
submitSeed?: number;
|
|
107
107
|
lastMaxWidth?: number;
|
|
108
|
-
|
|
108
|
+
hasMore: boolean;
|
|
109
|
+
}>({ hasMore: true }).current;
|
|
109
110
|
const lastMaxWidth = state.lastMaxWidth ?? 9999;
|
|
110
111
|
|
|
111
112
|
// Watch container
|
|
@@ -113,9 +114,7 @@ export function SearchBar(props: SearchBarProps) {
|
|
|
113
114
|
// Same logic from resetButtonRef
|
|
114
115
|
if (
|
|
115
116
|
rect.width === lastMaxWidth ||
|
|
116
|
-
(
|
|
117
|
-
index >= fields.length &&
|
|
118
|
-
rect.width > lastMaxWidth)
|
|
117
|
+
(!state.hasMore && rect.width > lastMaxWidth)
|
|
119
118
|
)
|
|
120
119
|
return false;
|
|
121
120
|
|
|
@@ -152,7 +151,7 @@ export function SearchBar(props: SearchBarProps) {
|
|
|
152
151
|
let maxWidth = containerRect.width;
|
|
153
152
|
if (
|
|
154
153
|
maxWidth === lastMaxWidth ||
|
|
155
|
-
(
|
|
154
|
+
(!state.hasMore && maxWidth > lastMaxWidth)
|
|
156
155
|
) {
|
|
157
156
|
return;
|
|
158
157
|
}
|
|
@@ -230,6 +229,7 @@ export function SearchBar(props: SearchBarProps) {
|
|
|
230
229
|
}
|
|
231
230
|
|
|
232
231
|
// Show or hide more button
|
|
232
|
+
state.hasMore = hasMore;
|
|
233
233
|
setElementVisible(buttonMore, hasMore);
|
|
234
234
|
setElementVisible(resetButton, true);
|
|
235
235
|
|