-
Notifications
You must be signed in to change notification settings - Fork 58
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
Add clear button by default to text input controls. #3017
Comments
@chipsnyder Agree that we should probably implement a “clear” button here (probably on the focused state, but I need to look at other examples to see what approach is most common), but also pretty much across the board on the focused states of text inputs (excluding RichText on the editor canvas, obviously). Would it make more sense to attack this on the component-level or only for this case specifically, and leave the component-level work to a later time? |
Component level sounds better to me! I'll update the ticket to reflect that. |
@iamthomasbishop @chipsnyder I'll be taking a look at this one! 👋 I'll outline some thoughts on how we might get started: There are ways to implement a native clear button in a text field for iOS and Android, but due to a limitation with React Native, only the iOS solution is supported. Fortunately, it can be handled in Javascript, however. (I discuss this a bit more generally in pbMoDN-34o-p2, if you'd like to read further about it.) In the places where the clear button is currently being used in Gutenberg Mobile (like the Link Picker, shown in the example above), it is indeed being handled by Javascript, so that sets a good precedent already. Background and ScopeTo kick off a discussion about adding a clear button to the text fields where it is not currently being used, I just made some reasonable assumptions about scope. These can be changed as the discussion evolves, of course, but just as a starting point:
DiscoveryTo get started on the first item, I took a closer look at all of the text fields that fall outside of the editor canvas, starting the search with any file with a This is great, because this component is mature and fairly all-purpose. It handles a lot of the basic behavior for TextInput in Gutenberg Mobile, and includes robust test cases already. Essentially, it is the "CustomTextInput" component wrapper I described in pbMoDN-34o-p2. However, Another case where the clear button behavior is being used is Search Control, which is one of the first TextInputs the user sees. Search Control is not using Search Control Implemented, but ad hoc and not at the component level: Social Link Input Not implemented at all (yet): Range Input Likely, the clear button is not applicable here: Next StepsGiven that there are some good precedents where the behavior we want already exists, next steps would be to define the scope, define the validity of the existing behavior, and apply that existing behavior to those areas. At the moment, pending further discussion of course, a potential path forward seems to be:
DiscussionOpening it up for questions for discussion, particularly on the scope. (More to the point, thanks for reading this far. 🤠 ) Since this is a trial task, there likely might be a disproportionate amount of information and discussion here given the actual end benefit for the user. Conversely -- in general, I believe that details are important, and since text input of any kind is a heavily used feature on Gutenberg, I welcome and appreciate any nuanced feedback here too. |
This step is a good start, as you commented, most of the use cases of
Not sure if we should expand the use of the
No worries about the amount of information, I think it makes sense to provide as much detail as possible, moreover in a trial project and touching a core functionality as text inputs, before heading to implementation 👍 . |
Right -- this is a good point, and I agree with you about not expanding the scope of A curious detail here is that the main native TextControl component is actually using
So Another option would be to break Cell out of BottomSheet into a more generic |
Good catch! Now after checking the
True,
To be honest, I'd expect the generic
@derekblank Wdyt? |
@fluiddot I think breaking the task into two parts is a good idea! I think I can get started with the first step since the work and scope seems clear:
These might actually be better as two separate PRs to reduce the complexity, especially since TextControl is using BottomSheetCell, and TextControl is used in a lot of places. Then, a possible third PR after getting more feedback from others:
Regarding the discussion to move BottomSheetCell outside BottomSheet: I reviewed the test cases for TextControl and BottomSheet, and there does not actually seem to be much behavior in the BottomSheetCell component that is specific to the BottomSheet itself. It all seems like general TextInput behavior. Reading through the docs on BottomSheetTextControl, however:
To make the situation even more complicated, BottomSheetTextControl does not use BottomSheetCell -- it imports TextInput directly from React Native. This makes sense, however, as BottomSheetTextControl is only used as a text editor component. I also agree with you that some of these components are no longer being used the sole purpose they were originally created for. Perhaps the broader discussion should include when we should make the distinction between a component that is just for editing text, and one that is just interactable. |
Yeah, eventually we should open this discussion if the |
Is your feature request related to a problem? Please describe.
As part of a recent empathy challenge, it was pointed out that it would be nice to add a clear button available by default for the focused state on all text input outside of the editor's canvas.
Describe the solution you'd like
I think a simple X in the text field or a clear button at the bottom would be nice maybe something similar to what the Link Picker has.
The text was updated successfully, but these errors were encountered: