Skip to content

Commit

Permalink
feat: change icon in search control reset button (#419)
Browse files Browse the repository at this point in the history
  • Loading branch information
ramazansancar authored Jan 24, 2025
1 parent 10586b2 commit 522defb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions docs/usage.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import { GeoSearchControl, OpenStreetMapProvider } from 'leaflet-geosearch';
const searchControl = new GeoSearchControl({
provider: new OpenStreetMapProvider(),
style: 'bar',
resetButton: '🔍', // Example of using a magnifying glass icon
});

map.addControl(searchControl);
Expand Down
4 changes: 3 additions & 1 deletion src/SearchControl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ const defaultOptions: Omit<SearchControlProps, 'provider'> = {
autoClose: false,
keepResult: false,
updateMap: true,
resetButton: '×',
};

const UNINITIALIZED_ERR =
Expand Down Expand Up @@ -110,6 +111,7 @@ interface SearchControlProps {
autoClose: boolean;
keepResult: boolean;
updateMap: boolean;
resetButton: string;
}

export type SearchControlOptions = Partial<SearchControlProps> & {
Expand Down Expand Up @@ -202,7 +204,7 @@ const Control: SearchControl = {
this.classNames.resetButton,
this.searchElement.form,
{
text: '×',
text: this.options.resetButton,
'aria-label': this.options.clearSearchLabel,
onClick: () => {
if (this.searchElement.input.value === '') {
Expand Down

0 comments on commit 522defb

Please sign in to comment.