-
-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Checkbox not setting properly on wow.marketshare.tsx page when commodity=on
set in url endings
#436
Comments
@coderabbitai please reply to this issue. :) |
Tip For best results, initiate chat on the files or code changes. @harjotgill, thank you for reaching out! I understand there's an issue with the checkbox not setting properly on the |
@coderabbitai can you please include these links in the issue description, this is where the checkbox is used I also mentioned it here |
Tip For best results, initiate chat on the files or code changes. @cohenaj194, I've noted the links where the checkbox issue is occurring in the |
Tip For best results, initiate chat on the files or code changes. @cohenaj194, I've prepared an updated issue description including the links to the specific lines where the checkbox is used in the
Please let me know if this meets your needs or if there are any other modifications you would like to make. |
I can work with that thanks @coderabbitai ❤️ I added this in can you view the details in the issue description? Are you also able to view the actual file? I will link the raw text url if that helps: We are concerned with lines 75 and 128 to 130 which used to set the commodity parameter Can you recommend a fix? |
Tip For best results, initiate chat on the files or code changes. @cohenaj194, thank you for providing the raw text link to the Issue Analysis
Suggested FixIt seems the issue might be related to how the
Here's how you can implement these changes: // In your form component where the checkbox is defined
<input type="checkbox" name="commodity" value="on" checked={searchParams.commodity === 'on'} onChange={handleCheckboxChange} />
<input type="hidden" name="commodity" value="off" />
// In your action function
const action: ActionFunction = async ({ request }) => {
const formData = await request.formData();
const formPayload = Object.fromEntries(formData);
// Ensure the commodity value is set based on the checkbox
formPayload.commodity = formData.has('commodity') ? 'on' : 'off';
// Rest of your action logic...
} This approach ensures that the Please let me know if this solution works for you or if you need further adjustments! Analysis chainScripts executedThe following scripts were executed for the analysis: Script: #!/bin/bash
# Fetch the content of the wow.marketshare.tsx file
curl https://raw.githubusercontent.com/ff14-advanced-market-search/saddlebag-with-pockets/master/app/routes/wow.marketshare.tsx
# Extract the relevant lines for analysis
sed -n '75p;128,130p' wow.marketshare.tsx
Length of output: 8552 |
Tip For best results, initiate chat on the files or code changes. @cohenaj194, thank you for providing the raw text URL. I've reviewed the relevant sections of the Current Implementation
Issue AnalysisIt seems the issue might be occurring due to how the
Suggested FixTo ensure the checkbox reflects the correct state, you can explicitly manage the state of the checkbox using React state hooks (if not already done) and ensure it syncs with URL parameters. Here’s a potential fix using React state hooks: import React, { useState, useEffect } from 'react';
// Assuming parseCheckboxBoolean correctly parses the checkbox state
const [commodity, setCommodity] = useState(parseCheckboxBoolean(defaultFormValuesMarketShare.commodity));
// Effect hook to update state based on URL parameter changes
useEffect(() => {
const params = new URLSearchParams(window.location.search);
const commodityParam = params.get('commodity');
if (commodityParam) {
setCommodity(commodityParam === 'true');
}
}, [window.location.search]);
// Ensure to pass `commodity` state to the checkbox component and update it on change
<Checkbox
checked={commodity}
onChange={(e) => setCommodity(e.target.checked)}
/> This code snippet does the following:
Please let me know if this approach suits your needs or if you need further modifications! Analysis chainScripts executedThe following scripts were executed for the analysis: Script: #!/bin/bash
# Fetch the content of the file and display the relevant lines
curl https://raw.githubusercontent.com/ff14-advanced-market-search/saddlebag-with-pockets/master/app/routes/wow.marketshare.tsx | sed -n '70,80p;128,132p'
Length of output: 889 |
@coderabbitai for context here is the parseCheckboxBoolean |
commodity=on
set in url endings
this kind of works when the default is on instead of off
|
Tip For best results, initiate chat on the files or code changes. @cohenaj194, thank you for providing the link to the Function AnalysisThe
Implications for Checkbox BehaviorThis function is crucial for interpreting the checkbox state from URL parameters or form submissions where the checkbox value is represented as a string ('on' or 'off'). The function ensures that only 'on' explicitly translates to Given this understanding, if the checkbox is not reflecting the expected state, it could be due to:
Suggested Next StepsTo further diagnose or fix the issue, you might want to:
If you need specific help with implementing these checks or any further modifications, feel free to ask! Analysis chain
Analysis chainScripts executedThe following scripts were executed for the analysis: Script: #!/bin/bash
# Fetch the content of the parseCheckboxBoolean function
curl https://raw.githubusercontent.com/ff14-advanced-market-search/saddlebag-with-pockets/master/app/utils/zodHelpers/index.ts
Length of output: 2185 |
@coderabbitai this was the fix, you are right when anything was passed into the checkbox and it was not 'on' it was being declared as a false value and the checkbox was set to off.
The problem is that a boolean was passed in not the string so Heres the corrected version
ref: #437 |
Tip For best results, initiate chat on the files or code changes. @cohenaj194, excellent work pinpointing the issue and implementing a fix! Your solution to explicitly check for the string 'on' with If there's anything more you need help with or any other part of the project you'd like to discuss, feel free to let me know. Great job on this fix! 🎉 Learnings added
|
Tip For best results, initiate chat on the files or code changes. @cohenaj194, fantastic work on diagnosing and fixing the checkbox issue! Your approach to explicitly check for the string 'on' with If there's anything else you need assistance with or any other aspect of the project you'd like to discuss, just let me know. Keep up the great work! 🚀 Learnings added
Learnings used
|
For future reference this was the actual answer from @spatiag. This is the kind of answer we hope to get out of @coderabbitai in the future hey, i looked into it and i think i found the problem basically, after parsing the url params, commodity is turned into a boolean
to fix it, we need to do also, if we want to use commodity=true/false instead of commodity=on/off in the url, we can do
in app\routes\wow.marketshare.tsx on line 128 and
in app\components\form\WoW\MarketshareForm\index.tsx on line 100 |
Tip For best results, initiate chat on the files or code changes. @cohenaj194, thank you for sharing this detailed solution and for setting clear expectations for the type of answers you find most helpful. Your feedback is invaluable as it helps us tailor our responses to be as useful and actionable as possible. The solution you've outlined does an excellent job of addressing the discrepancy between the data types expected by the checkbox and the actual data being passed. This kind of precise, actionable guidance is what we strive to provide. We'll aim to deliver this level of detail and clarity in our future interactions. If there's anything more specific you'd like to see in our responses or any other feedback you have, please let us know! Learnings added
Learnings used
|
Checkbox not setting properly on wow.marketshare.tsx page
There is an issue with the checkbox not setting properly at lines 75 and 128-130 in the file wow.marketshare.tsx. This issue was identified during the review of PR #435. For more details, see the PR at #435 and the specific comment at #435 (comment).
Relevant code sections:
overview
The commodity checkbox is always unchecked when you load the page even with
commodity=on
ex: https://saddlebagexchange.com/wow/marketshare?commodity=on
this still leave it unchecked by default
working example oof a checkbox in url params
https://saddlebagexchange.com/ffxiv/craftsim?hideExpertRecipes=false
https://github.com/ff14-advanced-market-search/saddlebag-with-pockets/blob/master/app/routes/ffxiv.craftsim._index.tsx
The text was updated successfully, but these errors were encountered: