Skip to content

Commit 5bb0b76

Browse files
fix(Quick Tags): Exclude Quick Tags control from ask form (#2138)
1 parent 0323747 commit 5bb0b76

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

src/utils/post_actions.js

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,15 @@ const addPostOptions = ([postFormButton]) => {
1313
if (!postFormButton) { return; }
1414

1515
const postActions = postFormButton.parentElement;
16+
const inAskForm = postActions.closest(keyToCss('form'))?.querySelector(keyToCss('anonToggle'));
1617

1718
postFormButton.before(
1819
...Object.keys(postOptions)
1920
.sort()
2021
.map(id => postOptions[id])
21-
.filter(postOption => !postActions.contains(postOption)),
22+
.filter(({ showInAskForm }) => showInAskForm ? true : !inAskForm)
23+
.map(({ element }) => element)
24+
.filter(element => !postActions.contains(element)),
2225
);
2326
};
2427

@@ -30,11 +33,15 @@ pageModifications.register(keyToCss('postFormButton'), addPostOptions);
3033
* @param {string} options.id Identifier for this post option (must be unique)
3134
* @param {string} options.symbolId RemixIcon symbol to use
3235
* @param {(event: PointerEvent) => void} options.onclick Click handler function for this button
36+
* @param {boolean} [options.showInAskForm] Whether to show the button in the ask form
3337
*/
34-
export const registerPostOption = async function ({ id, symbolId, onclick }) {
35-
postOptions[id] = label({ class: 'xkit-post-option', [displayBlockUnlessDisabledAttr]: '' }, [
36-
button({ click: onclick }, [buildSvg(symbolId)]),
37-
]);
38+
export const registerPostOption = async function ({ id, symbolId, onclick, showInAskForm = false }) {
39+
postOptions[id] = {
40+
element: label({ class: 'xkit-post-option', [displayBlockUnlessDisabledAttr]: '' }, [
41+
button({ click: onclick }, [buildSvg(symbolId)]),
42+
]),
43+
showInAskForm,
44+
};
3845

3946
pageModifications.trigger(addPostOptions);
4047
};

0 commit comments

Comments
 (0)