Skip to content

Commit

Permalink
Fixes: Clear TC autocomplete on selection, Allow commas in number inp… (
Browse files Browse the repository at this point in the history
#2597)

* Fixes: Clear TC autocomplete on selection, Allow commas in number inputs, Allow ctrl+v on artifact editor

* Resolve comments

---------

Co-authored-by: Failchon <[email protected]>
  • Loading branch information
failchon and Failchon authored Jan 16, 2025
1 parent 3fd901d commit beb669d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
5 changes: 3 additions & 2 deletions libs/common/ui/src/components/NumberInputLazy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ export function NumberInputLazy({
}, [valueProp])

const saveValue = () => {
let num = float ? parseFloat(value) : parseInt(value)
const normalizedValue = float ? value.replace(',', '.') : value
let num = float ? parseFloat(normalizedValue) : parseInt(normalizedValue)
if (isNaN(num)) {
num = 0
setValue(num.toString())
Expand All @@ -48,7 +49,7 @@ export function NumberInputLazy({
) => {
const val = event.target.value

if (val.match(float ? /[^0-9.-]/ : /[^0-9-]/)) {
if (val.match(float ? /[^0-9.,-]/ : /[^0-9-]/)) {
return event.preventDefault()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export function ArtifactSetsEditor({
artSetKey={''}
setArtSetKey={setSet}
label={'New Artifact Set'}
blurOnSelect={true}
getOptionDisabled={({ key }) =>
Object.keys(artSet).includes(key as ArtifactSetKey) ||
!key ||
Expand Down
5 changes: 4 additions & 1 deletion libs/gi/ui/src/components/artifact/editor/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ const InputInvis = styled('input')({
display: 'none',
})

const LineBreak = styled('br')()

function getDefaultSlotKey(
artifactSet?: ArtifactSetKey
): Extract<ArtifactSlotKey, 'flower' | 'circlet'> {
Expand Down Expand Up @@ -649,6 +651,8 @@ export function ArtifactEditor({
>
{t('editor.uploadBtn')}
</Button>
{/* https://github.com/frzyc/genshin-optimizer/pull/2597 */}
<LineBreak />
</label>
</Grid>
{shouldShowDevComponents && debugImgs && (
Expand Down Expand Up @@ -718,7 +722,6 @@ export function ArtifactEditor({
</CardThemed>
)}
</Grid>

{/* Right column */}
<Grid item xs={1} display="flex" flexDirection="column" gap={1}>
{/* substat selections */}
Expand Down

0 comments on commit beb669d

Please sign in to comment.