-
Notifications
You must be signed in to change notification settings - Fork 9
ERM-3894 On "add related agreement" focus should move to "Link agreement" button #1503
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: master
Are you sure you want to change the base?
Conversation
…ent" button * add focus
|
License CLA Stuck? (Developer should make sure that it is really stuck before clicking) |
* split focus logic
|
EthanFreestone
left a comment
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.
@CalamityC Thanks for the proposal here, I think this reinforces what I was hoping not to have to do on the call, but I think we need a more generic way of handling the
- form array new clicked
- focus on element
pattern
| 'buttonRef': triggerButton, | ||
| 'buttonStyle': value ? 'default' : 'primary', | ||
| 'id': `${id}-find-agreement-btn`, | ||
| 'id': triggerButtonId || `${id}-find-agreement-btn`, |
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.
If we already have a ref, I'm not sure why we need to append a custom id and then focus by that id
|
|
||
| const { selfLinkedWarning, setSelfLinkedWarning } = useLinkedWarning(change, input, parentAgreementId, triggerButton); | ||
|
|
||
| useEffect(() => { |
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.
This seems ok to me on first pass, but I do wonder if we're manually doing this on mount whether we're missing something.
useEffect on mount here I think means that if we decided to open the form up with an empty field instead of none (like periods in agreements) then this would focus.
Whereas what we're actually after is the focusing as a byproduct of being added...
I think alltold this probably should be dealt with more holistically.
Something like
const { focusRef, addCallback } useAddElementFocus
which we can implement within form components, and on creation of a new object handles the focusing of the ref
OR some kind of handling in form arrays specifically, where it internally tracks state, and on addition it can move focus to the new element...
Either way I think controlling from the overview of all elements makes more sense than each element controlling whether it gets focus or not.
| @@ -0,0 +1,9 @@ | |||
| const focusByIdWhenReady = (id) => { | |||
| requestAnimationFrame(() => { | |||
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.
I don't think we should be using animationFrames like this.
If we need to wait for a ref to be filled, we can use a callback ref and check whether the current is null or not
| @@ -0,0 +1,28 @@ | |||
| import refdata from './refdata'; | |||
|
|
|||
| export const relatedAgreements = [ | |||
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.
If I'm reading this right this is just a list of agreements. We should either use the agreements already in the centralised agreements resource, or add these to that list and extract by name/id in the test



add focus handling to RelatedAgreementField