-
Notifications
You must be signed in to change notification settings - Fork 4
feat: improve mui components #215
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -29,10 +29,16 @@ const DropdownCheckbox = ({ | |||||||||||||||||||||||||||||||||||
| allLabel, | ||||||||||||||||||||||||||||||||||||
| value = [], | ||||||||||||||||||||||||||||||||||||
| options, | ||||||||||||||||||||||||||||||||||||
| onChange | ||||||||||||||||||||||||||||||||||||
| onChange, | ||||||||||||||||||||||||||||||||||||
| ...rest | ||||||||||||||||||||||||||||||||||||
| }) => { | ||||||||||||||||||||||||||||||||||||
| const handleChange = (ev) => { | ||||||||||||||||||||||||||||||||||||
| const selected = ev.target.value; | ||||||||||||||||||||||||||||||||||||
| const rawValue = ev.target.value; | ||||||||||||||||||||||||||||||||||||
| const selected = Array.isArray(rawValue) | ||||||||||||||||||||||||||||||||||||
| ? rawValue | ||||||||||||||||||||||||||||||||||||
| : typeof rawValue === "string" | ||||||||||||||||||||||||||||||||||||
| ? rawValue.split(",") | ||||||||||||||||||||||||||||||||||||
| : []; | ||||||||||||||||||||||||||||||||||||
|
Comment on lines
+36
to
+41
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🌐 Web query:
💡 Result:
Sources: [1] Select API ( 🏁 Script executed: cat -n src/components/mui/dropdown-checkbox.js | head -60Repository: OpenStackweb/openstack-uicore-foundation Length of output: 2253 🏁 Script executed: cat -n src/components/mui/dropdown-checkbox.js | tail -n +60Repository: OpenStackweb/openstack-uicore-foundation Length of output: 1535 🏁 Script executed: rg "DropdownCheckbox" --type js --type tsx -B 2 -A 5 | head -80Repository: OpenStackweb/openstack-uicore-foundation Length of output: 111 🏁 Script executed: rg "DropdownCheckbox" --type js -B 2 -A 5 | head -100Repository: OpenStackweb/openstack-uicore-foundation Length of output: 8121 🏁 Script executed: cat -n src/components/mui/__tests__/dropdown-checkbox.test.jsRepository: OpenStackweb/openstack-uicore-foundation Length of output: 2252 Normalize option ID types when converting When MUI Select fires onChange from browser autofill, Proposed fix const handleChange = (ev) => {
const rawValue = ev.target.value;
- const selected = Array.isArray(rawValue)
- ? rawValue
- : typeof rawValue === "string"
- ? rawValue.split(",")
- : [];
+ const selected = (Array.isArray(rawValue)
+ ? rawValue
+ : typeof rawValue === "string"
+ ? rawValue.split(",")
+ : []
+ ).map((v) => {
+ if (v === "all") return "all";
+ const match = options.find(({ id }) => String(id) === String(v));
+ return match ? match.id : v;
+ });📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| if (selected.includes("all")) { | ||||||||||||||||||||||||||||||||||||
| if (!value.includes("all")) { | ||||||||||||||||||||||||||||||||||||
|
|
@@ -43,6 +49,8 @@ const DropdownCheckbox = ({ | |||||||||||||||||||||||||||||||||||
| onChange({ | ||||||||||||||||||||||||||||||||||||
| target: { name, value: selected.filter((v) => v !== "all") } | ||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||||
| onChange({ target: { name, value: ["all"] } }); | ||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||||
| // else if "all" is not selected we just send selection | ||||||||||||||||||||||||||||||||||||
|
|
@@ -59,6 +67,7 @@ const DropdownCheckbox = ({ | |||||||||||||||||||||||||||||||||||
| multiple | ||||||||||||||||||||||||||||||||||||
| value={value} | ||||||||||||||||||||||||||||||||||||
| onChange={handleChange} | ||||||||||||||||||||||||||||||||||||
| {...rest} | ||||||||||||||||||||||||||||||||||||
| input={<OutlinedInput label={label} />} | ||||||||||||||||||||||||||||||||||||
| renderValue={(selected) => { | ||||||||||||||||||||||||||||||||||||
| if (selected.includes("all")) { | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Redux clear events are no longer synced to local
msgData.Line 63 only updates local state when
snackbarMessage?.htmlis non-empty. WhenCLEAR_SNACKBAR_MESSAGEresets html to"", localmsgDatais not cleared, so stale content can persist until another local action closes it.🛠️ Proposed fix
useEffect(() => { if (!empty(snackbarMessage?.html)) { setMsgData(snackbarMessage); + } else { + setMsgData({}); } }, [snackbarMessage]);📝 Committable suggestion
🤖 Prompt for AI Agents