Skip to content

Commit 2fef58e

Browse files
committed
* fix not selecting select > optgroup > option: vuejs/core#13486 @ <PostQueryForm> & <PostQueryFormWidgetSelectParam>
* fix only reset fetched query but not refetch it when `isTriggeredByQueryForm` is `true` @ `pages/posts.vue` * fix not converting `'true'` or `'false'` in string to bool when param have no preprocessor in `parseParamRoute()` @ `utils/post/queryForm/useQueryForm.ts` @ fe
1 parent 3ebda4d commit 2fef58e

4 files changed

Lines changed: 10 additions & 9 deletions

File tree

fe/src/components/post/queryForm/QueryForm.vue

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,11 @@
2828
</option>
2929
<option value="postedAt">发帖时间</option>
3030
<optgroup label="帖子ID">
31-
<option value="tid">主题帖tid</option>
32-
<option value="pid">回复帖pid</option>
33-
<option value="spid">楼中楼spid</option>
31+
<option
32+
v-for="(postID, index) in postID" :key="postID"
33+
:value="postID" :selected="postID === orderBy.value">
34+
{{ postTypeText[index] }}{{ postID }}
35+
</option>
3436
</optgroup>
3537
</select>
3638
<select

fe/src/components/post/queryForm/widget/SelectParam.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
<option :disabled="currentParam !== 'add'" :hidden="currentParam !== 'add'" value="add">New...</option>
66
<optgroup v-for="(group, groupName) in paramsGroup" :key="groupName" :label="groupName">
77
<option
8-
v-for="(paramDescription, paramName) in group"
9-
:key="paramName" :value="paramName">
8+
v-for="(paramDescription, paramName) in group" :key="paramName"
9+
:value="paramName" :selected="paramName === currentParam">
1010
{{ paramDescription }}
1111
</option>
1212
</optgroup>

fe/src/pages/posts.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ watchDeep(() => [route.query, route.params], async (_discard, [oldQuery, oldPara
134134
const isNewQuery = compareRouteIsNewQuery(to, from);
135135
if (to.hash === '' && (isTriggeredByQueryForm || isNewQuery))
136136
void nextTick(() => { window.scrollTo({ top: 0 }) });
137-
if (isNewQuery)
137+
if (isTriggeredByQueryForm || isNewQuery)
138138
await parseRouteThenFetch(to, isTriggeredByQueryForm);
139139
140140
/** must invoke {@link parseRouteThenFetch()} before {@link queryClient.resetQueries()} */

fe/src/utils/post/queryForm/useQueryForm.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,11 +150,10 @@ export const useQueryForm = <
150150
})
151151
.map(_.unary(fillParamDefaultValue))
152152
.each(param => {
153+
param.subParam.not = boolStrToBool(param.subParam.not);
153154
const preprocessor = deps.paramsPreprocessor[param.name];
154-
if (preprocessor !== undefined) {
155+
if (preprocessor !== undefined)
155156
preprocessor(param);
156-
param.subParam.not = boolStrToBool(param.subParam.not);
157-
}
158157
const isUniqueParam = (p: UnknownParam): p is UniqueParam => p.name in uniqueParams.value;
159158
if (isUniqueParam(param))
160159
uniqueParams.value[param.name as keyof UniqueParams] = param;

0 commit comments

Comments
 (0)