Framework/React

[Material UI] Dialog μ»΄ν¬λ„ŒνŠΈ ν™”μ‚΄ν‘œ ν‚€ (PgUp, PgDn) Internal scroll μΆ”κ°€ν•˜λŠ” 방법

yuri lee 2024. 1. 24. 08:49
λ°˜μ‘ν˜•

Intro

μ•ˆλ…•ν•˜μ„Έμš”. 이번 μ‹œκ°„μ—λŠ” MUI Dialog Component μ—μ„œ ν™”μ‚΄ν‘œ ν‚€ (PgUp, PgDn) Internal scroll 을 μΆ”κ°€ν•˜λŠ” 방법에 λŒ€ν•΄ μ•Œμ•„λ³΄κ² μŠ΅λ‹ˆλ‹€.

 

Mui Dialog Component

<React.Fragment>
  <Button variant="outlined" onClick={handleClickOpen}>
    Open full-screen dialog
  </Button>
  <Dialog
    fullScreen
    open={open}
    onClose={handleClose}
    TransitionComponent={Transition}
  >
    <AppBar sx={{ position: 'relative' }}>
      <Toolbar>
        <IconButton
          edge="start"
          color="inherit"
          onClick={handleClose}
          aria-label="close"
        >
          <CloseIcon />
        </IconButton>
        <Typography sx={{ ml: 2, flex: 1 }} variant="h6" component="div">
          Sound
        </Typography>
        <Button autoFocus color="inherit" onClick={handleClose}>
          save
        </Button>
      </Toolbar>
    </AppBar>
    <List>
      <ListItemButton>
        <ListItemText primary="Phone ringtone" secondary="Titania" />
      </ListItemButton>
      <Divider />
      <ListItemButton>
        <ListItemText
          primary="Default notification ringtone"
          secondary="Tethys"
        />
      </ListItemButton>
    </List>
  </Dialog>
</React.Fragment>

 

MUI Full Dialog μ˜ˆμ‹œλŠ” λ‹€μŒκ³Ό κ°™μŠ΅λ‹ˆλ‹€. μœ„ μ½”λ“œ ν™œμš© μ‹œμ— 기본적으둜 ν™”μ‚΄ν‘œ λ°©ν–₯ν‚€ 슀크둀이 μž‘λ™ν•˜μ§€ μ•ŠμŠ΅λ‹ˆλ‹€. PgUp, PgDn λ²„νŠΌλ„ λ§ˆμ°¬κ°€μ§€κ³ μš”. 

 

How to solve problem

<Dialog open={open} aria-labelledby="dialog-title">
  <DialogTitle id="dialog-title">Modal title</DialogTitle>
  <DialogContent dividers tabIndex={0}>
    <div className={classes.DialogContent}>
    </div>
  </DialogContent>
</Dialog>

 

DialoContent νƒœκ·Έμ— tabIndex={0} 속성을 μΆ”κ°€ν•˜λ©΄ ν™”μ‚΄ν‚€ ν‘œλ₯Ό 톡해 up & down μŠ€ν¬λ‘€μ„ μ‹€ν–‰μ‹œν‚¬ 수 μžˆμŠ΅λ‹ˆλ‹€. PgUp, PgDn λ²„νŠΌλ„ 잘 μž‘λ™ν•˜κ³ μš”. 

 

Conclusion

Mui Full Dialog λ₯Ό μ΄μš©ν•˜λ©΄μ„œ 슀크둀이 생긴 화면에 λŒ€ν•΄ ν™”μ‚΄ν‘œν‚€κ°€ 먹지 μ•Šμ•„ λ‹΅λ‹΅ν–ˆλŠ”λ°, ν•΄λ‹Ή 속성을 μ μš©ν•˜λ‹ˆ λ°”λ‘œ μž‘λ™λ˜μ–΄ νŽΈν•˜κ²Œ μ΄μš©ν•  수 μžˆμ—ˆμŠ΅λ‹ˆλ‹€ :) 


 

https://mui.com/material-ui/react-dialog/

https://github.com/mui/material-ui/issues/24953

λ°˜μ‘ν˜•