Skip to content

Commit

Permalink
Fix: #5063 - Bug: Census Place disappears temporarily when choosing C…
Browse files Browse the repository at this point in the history
…ensus Date from the Census dropdown
  • Loading branch information
fisharebest committed Nov 28, 2024
1 parent 9b9bc00 commit b351811
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ use Fisharebest\Webtrees\I18N;
const form = select.closest('form');

form.querySelector('[id$=CENS-DATE]').value = option.dataset.wtDate;
form.querySelector('[id$=CENS-PLAC]').value = option.dataset.wtPlace;
$(form.querySelector('[id$=CENS-PLAC]')).typeahead('val', option.dataset.wtPlace);
});
});
</script>

11 comments on commit b351811

@kiwi3685
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wrapping the new line in $(.....) doesn't seem to work. It's OK without that.

@fisharebest
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you be more specific about "doesn't seem to work".

This is what I see do:

Enter a value "Foo" into the place.
Select a census date/place (e.g. 1841 England).
The place changes to "England"
Click/tab in the place field.
Click/tab away from it.

Before the change, the field reverted to "Foo".
After the change, the fields remains as "England".

The explanation is that this field uses typeahead (autocomplete), and we need to use the typeahead API to set this.
The documentation is here: https://github.com/corejavascript/typeahead.js/blob/master/doc/jquery_typeahead.md#jquerytypeaheadval-val

@sleebooth
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why can't the value in the place field remain at "Foo"? That would be my preferred result.

To achieve that would presumably mean testing to see if the place already contains a value and only updating that field with the typeahead if it is empty?

@mpwt
Copy link
Contributor

@mpwt mpwt commented on b351811 Nov 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why don't you first select the desired census and then overwrite the location? The location is defined in the census template, but can be overwritten.

@fisharebest
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why can't the value in the place field remain at "Foo"? That would be my preferred result.

You set it to "Foo" (by typing).
You changed it to, say, "England", by selecting the date/place from the list.

Setting focus to the place field shouldn't replace "England" with whatever was there before.

@sleebooth
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, but if I accidentally choose the wrong census initially and enter the place, changing the census choice deletes the place, which seems wrong

@fisharebest
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't get it?

You type Scotland into the place.
You select 1841/England (accidently).
The system enters England into the place.
You don't want this? You want it to stay as Scotland?

The whole point of this select/drop-down is a quick way to fill date/place.

@kiwi3685
Copy link
Contributor

@kiwi3685 kiwi3685 commented on b351811 Nov 29, 2024 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sleebooth
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the more likely scenario (an actual case):

I select 1841/England - I should have chosen the 1851/England census but don't realise it yet.
The system enters 06 JUN 1841 into the date and England into the place:
I type the town first so that I can use auto-suggestions which add the county and country:
I have to select England in the place and then overtype St Ives into the place
The system suggests several options that begin with St Ives:
I choose St Ives, Cornwall, England (a commonly used place for me).

Realising I have chosen the 1841/England census rather than the 1851/England Census, I select the 1851/England Census
The system enters 30 MAR 1851 into the date and England into the place, overwriting St Ives, Cornwall, England

Can you see that making the system enter the country (England in the above example) into the place is not helpful?
The reason being that I use the system's automatic suggestions of the place, beginning with the town, to fill the place.

@fisharebest
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason being that I use the system's automatic suggestions of the place, beginning with the town, to fill the place.

Ah. And you do it "out-of-sequence" - i.e. before using the date/place selector.

We can only update it if it doesn't contain the new string.

Thus "England" would overwrite "Scotland", but not "London, England"

@kiwi3685
Copy link
Contributor

@kiwi3685 kiwi3685 commented on b351811 Nov 30, 2024 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.