-
Notifications
You must be signed in to change notification settings - Fork 0
Add adoptions #1018
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
base: release26.3-SNAPSHOT
Are you sure you want to change the base?
Add adoptions #1018
Changes from all commits
4f4f407
5f847a4
a94b5e8
c586768
a636c22
1a0f9d9
9f83b0b
4ef4888
c35db6c
221dd32
2887915
0029601
b19a11b
a1edccc
fddb301
ac37b2f
0b749ac
86b9513
0f10624
67fab92
d601463
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
|
Collaborator
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. Risk here: "@mui/x-data-grid": "^8.28.6", Apparently this only supports @mui/material 5, 6, or 7 but this project pins @ 9. Fine to leave this, just know this is unsupported and we'll have to keep an eye on this to verify it doesn't break on any future updates. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
| /* | ||
| * | ||
| * * Copyright (c) 2026 Board of Regents of the University of Wisconsin System | ||
| * * | ||
| * * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * * you may not use this file except in compliance with the License. | ||
| * * You may obtain a copy of the License at | ||
| * * | ||
| * * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * * | ||
| * * Unless required by applicable law or agreed to in writing, software | ||
| * * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * * See the License for the specific language governing permissions and | ||
| * * limitations under the License. | ||
| * | ||
| */ | ||
| import * as React from 'react'; | ||
| import { useState } from 'react'; | ||
| import { GridRenderEditCellParams, useGridApiContext } from '@mui/x-data-grid'; | ||
| import { Autocomplete, TextField } from '@mui/material'; | ||
|
|
||
| interface AutoCompleteEditCellParams { | ||
| options: any[] | ||
| required: boolean; | ||
| multiple?: boolean; | ||
| disableClearable?: boolean; | ||
| returnValueOnly?: boolean; | ||
| } | ||
|
|
||
| export const AutoCompleteEditCell = (props: GridRenderEditCellParams & AutoCompleteEditCellParams) => { | ||
| const { id, field, value, options, required, multiple, disableClearable, returnValueOnly } = props; | ||
| const apiRef = useGridApiContext(); | ||
| const [open, setOpen] = useState(true); | ||
|
|
||
| const handleChange = (event: any, newValue: any) => { | ||
| const val = returnValueOnly && newValue ? newValue.value : newValue; | ||
| apiRef.current.setEditCellValue({ id, field, value: val }); | ||
| if (!multiple && (newValue || newValue === null)) { | ||
| apiRef.current.stopCellEditMode({ id, field }); | ||
| } | ||
| }; | ||
|
|
||
| const handleKeyDown = (event: React.KeyboardEvent) => { | ||
| if (event.key === 'Tab') { | ||
| apiRef.current.stopCellEditMode({ id, field }); | ||
| } | ||
| }; | ||
|
|
||
| const isError = required && (value === null || value === undefined || (Array.isArray(value) && value.length === 0) || value === ''); | ||
| const selectedOption = multiple ? (value || []) : (options.find(opt => opt.value === value || opt === value || (typeof value === 'object' && value !== null && opt.value === value.value)) || null); | ||
|
|
||
| return ( | ||
| <Autocomplete | ||
| options={options} | ||
| getOptionLabel={(option) => option.label || ''} | ||
| value={selectedOption} | ||
| onChange={handleChange} | ||
| open={open} | ||
| onOpen={() => setOpen(true)} | ||
| onClose={(event, reason) => { | ||
| if (reason === 'selectOption' || reason === 'blur' || reason === 'escape') { | ||
| setOpen(false); | ||
| } | ||
| }} | ||
| fullWidth | ||
| multiple={multiple} | ||
| disableClearable={disableClearable} | ||
| isOptionEqualToValue={(option, value) => { | ||
| const val = (value && typeof value === 'object' && 'value' in value) ? value.value : value; | ||
| return option.value === val; | ||
| }} | ||
| renderInput={(params) => ( | ||
| <TextField | ||
| {...params} | ||
| autoFocus | ||
| variant="standard" | ||
| onKeyDown={handleKeyDown} | ||
| required={required} | ||
| error={isError} | ||
| /> | ||
| )} | ||
| /> | ||
| ); | ||
| }; |
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.
Assuming this file works correctly as i'm not able to test all these nodes.
Ran it through Claude just to double check and the only catch is that it looks like this also deals with the @mui/material issue i mentioned in another comment. This file shows @mui/material resolved to 9.3.1 while @mui/x-data-grid resolved to 8.29.2. x-data-grid's peerDependencies only allow @mui/material 5, 6, and 7. Same as the other comment, feel free to leave this but just keep an eye on any future breakage due to this package combo being unsupported.