Skip to content
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

Material widgets all displaying readonly fields as disabled (greyed out/non-interactive) #1667

Closed
juliankigwana opened this issue Mar 20, 2020 · 3 comments

Comments

@juliankigwana
Copy link
Contributor

juliankigwana commented Mar 20, 2020

Prerequisites

Description

The Material UI package has a readOnly property that "prevents the user from changing the value of the field (not from interacting with the field).". However, all the widgets in the RJSF material package set the fields as disabled (grey out), with no interaction. Looking into the code I see they all have something like this:

<TextField
  id={id}
  label={label || schema.title}
  autoFocus={autofocus}
  required={required}
  disabled={disabled || readonly}
  name={name}
  type={schema.type as string}
  value={value ? value : ''}
  onChange={_onChange}
  onBlur={_onBlur}
  onFocus={_onFocus}
/>

The fix is simple, they just need to be changed to:

<TextField
  id={id}
  label={label || schema.title}
  autoFocus={autofocus}
  required={required}
  disabled={disabled}
  inputProps={{
    readOnly: readonly
  }}
  name={name}
  type={schema.type as string}
  value={value ? value : ''}
  onChange={_onChange}
  onBlur={_onBlur}
  onFocus={_onFocus}
/>

I would fix this myself, however due to problems outlined here I am unable to :(

Expected behavior

Setting a field to readonly, would make it readonly not disabled.

Actual behavior

Setting a field to readonly makes it disabled.

@dekelb
Copy link

dekelb commented Mar 21, 2020

This is related to #1647 (which I already offered to open PR for, but got no response for my suggestion there). There are more fields (not just the readonly), which are supported by material-ui, and there should be a generic way to have access to them.

@epicfaace epicfaace added this to To do in PRs May 23, 2020
@epicfaace epicfaace added this to Low priority in Issues - @rjsf/material-ui May 23, 2020
@mdornseif
Copy link
Contributor

in antd this can be configured in the form context via readonlyAsDisabled in the formContext.
See here.

@stale
Copy link

stale bot commented Feb 23, 2023

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Please leave a comment if this is still an issue for you. Thank you.

@stale stale bot added the wontfix label Feb 23, 2023
@stale stale bot closed this as completed Mar 9, 2023
Issues - @rjsf/material-ui automation moved this from Low priority to Closed Mar 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Development

No branches or pull requests

3 participants